menu

WPGraphQL

Free Open Source WordPress plugin that adds an extendable GraphQL Schema and API to your WordPress site

Channels
Team

Multiple providers?

February 6, 2019 at 2:55pm

Multiple providers?

February 6, 2019 at 2:55pm

Bit out of scope perhaps, but just asking for your $0.02.

I'm planning a site which will be approximately:

Next.js->Apollo->

WPGraphQL->Wordpress &

Shopify

So, Next.js front end, pulling WP stuff via WPGraphQL and pulling Shopify stuff via either their Storefront API or the JS Buy SDK.

Assuming I can end up using the Shopify Storefront (GraphQL) API, would you say that the approach mentioned here (Gateway API: https://medium.com/open-graphql/apollo-multiple-clients-with-react-b34b571210a5) is the best way to structure things to let Apollo pull data from multiple providers?


February 6, 2019 at 9:38pm

@paulisloud I think the approach in that article works well. I've got one App that uses that approach and we haven't run into any major snags.

  • reply
  • like

February 7, 2019 at 10:56am

I found someone else that just wraps another ApolloProvider around the first one: https://spectrum.chat/?t=4c8e2898-86b0-4706-9771-7940523634f0 and uses an as prop I can't find much about.

And then there's also react-apollo-multiple-clients: (https://github.com/titel-media/react-apollo-multiple-clients) which was made as a followup of that original Medium post.

Just to clarify: I don't know what the best way is, just sharing my findings.

  • reply
  • like

Thanks for the feedback @jasonbahl

  • reply
  • like

@rafaelderolez that was my first thought, and it looks like the multiple client approach they've taken will indeed allow you to direct the right query to the right client. Thanks for sharing

like-fill
1
  • reply
  • like

Will give both of these a shot

  • reply
  • like

@paulisloud If you get the first one to work, let me know! I didn't get far with the as prop.

I'm also wondering how this ties in with the Next.js's with-apollo example I'm using. It seems to extract the cache when using withApolloClient (https://github.com/zeit/next.js/blob/canary/examples/with-apollo/lib/with-apollo-client.js)

like-fill
1
  • reply
  • like

April 23, 2019 at 8:30am