kidunot89 / wp-graphql-composer

A library of customizable WordPress React-Apollo components
MIT License
21 stars 2 forks source link

unified GraphQL Schema ? #2

Open tomByrer opened 5 years ago

tomByrer commented 5 years ago

no other GraphQL server for WordPress has been developed to my knowledge

Seems for PHP, WPGraphQL is the way to go. But there are many other ways to use a WP database to serve GraphQL. You could just find a GraphQL server & connect to the MySQL DB directly or via ORM, but creating the API would be a bit of work.

NodeJS has a few solutions. Some of the more built up wrappers are jsindos/acfq that can use ACF & also ramsaylanier/WordExpress-Server. Not sure if these would be more performant than WPGraphQL or easier to use (since you're using React anyhow), but I'm leaning towards NodeJS solution for SSR.

That said, I wonder if there could be an unified GraphQL Schema that would be transportable between platforms?

kidunot89 commented 5 years ago

Those are both NodeJS solutions requiring a separate NodeExpress server to be run along side the PHP server serving WordPress. IMO, its not a good solution. I would recommend using WPGraphQL over them simply because as a plugin it has direct access to the WP API and database, plus you don't put yourself at risk by daisy-chaining you data to external entity to build the schema (which is more work on your server btw) before handling the request from you client, which is what the two you mentioned. I handling SSR by creating a dummy theme and wrapping my react app in it. That way I can leave SEO to Wordpress. If you can see an example here in one of my other repos.

tomByrer commented 5 years ago

Hmmm, I think WordExpress-Server can run without PHP.

But anyway, the point of my question was not to debate which solution is better, but to see if on the GraphQL end if GQL code could be shared?

kidunot89 commented 5 years ago

I'm not sure what you mean. Do you mean to link multiple GraphQL Servers together in one react app?.