Since all GraphQL queries are known at build time, I am wondering if I could use the information given by the files generated by relay-compiler to:
GET /graphql?query_id=eyBuaWNl123 or POST /graphql?mutation_id=abcdefgh321What would the pseudo code look like for this?
Related:
RFC: GraphQL Persisted Documents
https://github.com/graphql/express-graphql/pull/109
persistgraphql
https://github.com/apollographql/persistgraphql
There is an open PR about it already
@sibelius
Ah I see, this one right?
https://github.com/facebook/relay/pull/1846
Here is how I implement it in Relay and GraphQL, using md5 and Redis
Relay
https://github.com/staylor/wp-relay-app/blob/master/src/relay/fetcher.js#L26
GraphQL
https://github.com/staylor/wp-graphql/blob/master/src/server.js#L42
I persist the queries when starting the server:
https://github.com/staylor/wp-relay-app/blob/master/package.json#L36
Script to persist queries:
https://github.com/staylor/wp-relay-app/blob/master/tools/persistedQueries.js
For a compile time solution, see relay-compiler-plus. The hard work is done for you by this custom compiler at compile time.
Most helpful comment
Here is how I implement it in Relay and GraphQL, using
md5and RedisRelay
https://github.com/staylor/wp-relay-app/blob/master/src/relay/fetcher.js#L26
GraphQL
https://github.com/staylor/wp-graphql/blob/master/src/server.js#L42
I persist the queries when starting the server:
https://github.com/staylor/wp-relay-app/blob/master/package.json#L36
Script to persist queries:
https://github.com/staylor/wp-relay-app/blob/master/tools/persistedQueries.js