Comments (4)
Don't know if make sense but maybe It could modify the exported queries when there's multiple operations.
from:
module.exports = doc;
module.exports["MyQuery"] = oneQuery(doc, "MyQuery");
module.exports["MyMutation"] = oneQuery(doc, "MyMutation");
to:
module.exports = doc;
module.exports["MyQuery"] = oneQuery(doc, "MyQuery");
module.exports["MyMutation"] = oneQuery(doc, "MyMutation");
module.exports["MyQuery"].documentId = "HASH1";
module.exports["MyMutation"].documentId = "HASH2";
I guess the challenge here could be getting the operation name from the queryMap
keys and then concatenate the module.exports["operationName"].documentId = "hash";
for each query at the end of the content
.
from graphql-persisted-document-loader.
Hey! @sebas5384 I've been thinking about this, and based on the code I think we may need to do something different. In practice, you persist a document, not just a single query. In the case of a document with different operations, the documentId should still be the same, and you'd refer to the operation you want to execute with both the documentId and the operationName.
I think I'll be adding those changes, as right now PersistGraphQL splits the documents per operation and that's not what we really want to do. Also, PersistGraphQL will be deprecated, so we might just as well remove our dependency with it.
Any thoughts? Concerns? Anything you think I may be missing?
from graphql-persisted-document-loader.
Having said that, it seems that this is not really how the rest of the Apollo libraries work, as they all work with documents that contain a single operation, or split them into separate documents if that's the case. It feels now that maybe documentId
is misleading in this case.
from graphql-persisted-document-loader.
Hey @leoasis , yeah when I commit the code I thought about the documentId
since is not the "document id" anymore is the "operation id".
Maybe we could change that to operationId
and get rid of the documentId
.
About the PersistGraphQL being deprecated, are thinking on a new approach or something like that? or about these code:
const { ExtractGQL } = require('persistgraphql/lib/src/ExtractGQL');
const queryTransformers = require('persistgraphql/lib/src/queryTransformers');
if it is the code, then I guess we could open an issue as the apollographql/persistgraphql#67 states, what do you think?
Sorry about the delay to answer you! I had to think for a while about my answer.
from graphql-persisted-document-loader.
Related Issues (7)
- publish new npm version HOT 2
- Fix security vulnerabilities HOT 4
- Adding 'doc.documentID' to EOL breaks eval HOT 5
- Fails when used with queries that include imports
- Webpack can load modules recursively HOT 1
- Using with create-react-app and integration with babel-plugin-graphql-tag. Question about hashing cost client side. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-persisted-document-loader.