Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[modern] Persisted GraphQL Queries in Modern? #2008

Open
johntran opened this issue Aug 2, 2017 · 5 comments
Open

[modern] Persisted GraphQL Queries in Modern? #2008

johntran opened this issue Aug 2, 2017 · 5 comments
Labels

Comments

@johntran
Copy link

johntran commented Aug 2, 2017

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:

  1. Create ID's
  2. Send those ID's to the GraphQL server as a GET/POST: ex GET /graphql?query_id=eyBuaWNl123 or POST /graphql?mutation_id=abcdefgh321
  3. Get a response back equal to what you would normally get from sending in a GraphQL query string.

What would the pseudo code look like for this?

Related:
RFC: GraphQL Persisted Documents
graphql/express-graphql#109
persistgraphql
https://github.com/apollographql/persistgraphql

@sibelius
Copy link
Contributor

sibelius commented Aug 2, 2017

There is an open PR about it already

@johntran
Copy link
Author

johntran commented Aug 2, 2017

@sibelius

Ah I see, this one right?
#1846

@staylor
Copy link
Contributor

staylor commented Aug 10, 2017

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

@yusinto
Copy link
Contributor

yusinto commented Nov 12, 2017

For a compile time solution, see relay-compiler-plus. The hard work is done for you by this custom compiler at compile time.

@stale
Copy link

stale bot commented Jan 9, 2022

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.

@stale stale bot added the wontfix label Jan 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants