question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC] Bring your own GraphQL library

See original GitHub issue

Right 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:

  1. We grab the API_PROXY_PATH value from the redwood.toml configuration to point to the URL to your GraphQL server.
  2. 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:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
peterpcommented, Sep 15, 2020

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.

0reactions
peterpcommented, Mar 19, 2021

We allow this now.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found