Open johntran opened 7 years ago
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.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
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
orPOST /graphql?mutation_id=abcdefgh321
What would the pseudo code look like for this?
Related:
RFC: GraphQL Persisted Documents
https://github.com/graphql/express-graphql/pull/109persistgraphql
https://github.com/apollographql/persistgraphql