[RFC] Bring your own GraphQL library
See original GitHub issueRight now Redwood ships with Apollo’s GraphQL client out of the box. We don’t know if that will change, but we would love to give you the ability to switch to the GraphQL client of your preference.
As a user, nothing will change if you’re happy with the GraphQL client! This is only for people who would want to change the client.
How does this work right now?
Right now we initialise the Apollo GraphQL library in <RedwoodProvider>
where we do two things:
- We grab the
API_PROXY_PATH
value from theredwood.toml
configuration to point to the URL to your GraphQL server. - We determine if you’re users are authenticated and we put the appropriate
Authorization
headers into the GraphQL clients configuration.
How would you specify your own GraphQL client?
// ./web/src/index.js
return (
<AuthProvider>
<RedwoodProvider
graphQLClient={({ url, headers }) => new GraphQLClient(url, { headers })}
queryHandler={({ query, variables }) => useQuery(query, { variables })}
>
</RedwoodProvider>
</AuthProvider>
)
We would provide the url to your GraphQL server and headers to facilitate authentication, which you would pass to the configuration of your client. You would also need to let us know how to run run queries.
Let me know what you think!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:6 (6 by maintainers)
Top Results From Across the Web
rfc/005-graphql-api.md at main · appwrite/rfc - GitHub
Load all Appwrite relevant routes, models, and Database collections into the GraphQL parser library. Any GET routes should be loaded as GraphQL queries,...
Read more >The next step for realtime data in GraphQL
If you've been following along with the GraphQL community, there's a lot of buzz about the new RFC process for making improvements to...
Read more >GraphQL Foundation Monthly Newsletter February 2021
GraphQL has redefined how developers work with APIs and client-server interactions. And as the community works hard to foster the growth and ...
Read more >GraphQL posts | StepZen blog
GraphQL supports subscriptions. StepZen makes it really easy, but unlike other systems, any query can be converted to a subscription. The query does...
Read more >graphql-scalars - npm
A library of custom GraphQL scalar types for creating precise type-safe GraphQL schemas. Installation. npm install --save graphql-scalars. or
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it’s largely subjective, but maybe bundle size and simplicity are really important to your particular use case and you don’t need something as heavy as Apollo.
So, the main reason for this is to consider is that we used Apollo v2 and it took us several weeks to upgrade to v3. You might decide that there are features that are important for you and you don’t want to be trapped into whatever Redwood decides. Alternatively you might decide that you actually want to stay on v2 and don’t want to upgrade to v3 just yet.
We allow this now.