Git Product home page Git Product logo

Comments (4)

sebas5384 avatar sebas5384 commented on June 18, 2024

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.

leoasis avatar leoasis commented on June 18, 2024

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.

leoasis avatar leoasis commented on June 18, 2024

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.

sebas5384 avatar sebas5384 commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.