how to match queries with apollo's refetchQueryWhy do GraphQL fragments need __typename in queries?React-apollo v2 - Youshido GraphQlBundle - refetch two queries simultaneouslyUpdate Apollo GraphQL cache without using refetchQueries?How to pass multiple queries into refetchQueries in apollo/graphqlWhy I got error: Cannot query field xx on type “Query”?GraphQL dynamic query buildingAWS appsync Apollo client and multiple queries/mutations issueResolve queries that are supersets of cached queries in Apollo ClientRefetchQueries does not correctly update the storeHow to call a GraphQL query/mutation from an Express server backend?

Feels like I am getting dragged in office politics

What is the range of this combined function?

Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?

How does a Swashbuckler rogue "fight with two weapons while safely darting away"?

What is the difference between `a[bc]d` (brackets) and `ab,cd` (braces)?

What does "rf" mean in "rfkill"?

Find the coordinate of two line segments that are perpendicular

How to stop co-workers from teasing me because I know Russian?

Binary Numbers Magic Trick

Was it really necessary for the Lunar Module to have 2 stages?

What does YCWCYODFTRFDTY mean?

Colliding particles and Activation energy

"ne paelici suspectaretur" (Tacitus)

Transfer over $10k

Need help understanding harmonic series and intervals

How to back up a running remote server?

Why does nature favour the Laplacian?

Is it cheaper to drop cargo drop than to land it?

Examples of non trivial equivalence relations , I mean equivalence relations without the expression " same ... as" in their definition?

Phrase for the opposite of "foolproof"

When did stoichiometry begin to be taught in U.S. high schools?

Confusion about capacitors

Why does processed meat contain preservatives, while canned fish needs not?

Are Boeing 737-800’s grounded?



how to match queries with apollo's refetchQuery


Why do GraphQL fragments need __typename in queries?React-apollo v2 - Youshido GraphQlBundle - refetch two queries simultaneouslyUpdate Apollo GraphQL cache without using refetchQueries?How to pass multiple queries into refetchQueries in apollo/graphqlWhy I got error: Cannot query field xx on type “Query”?GraphQL dynamic query buildingAWS appsync Apollo client and multiple queries/mutations issueResolve queries that are supersets of cached queries in Apollo ClientRefetchQueries does not correctly update the storeHow to call a GraphQL query/mutation from an Express server backend?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















My fundimental question is do the variables for queries need to be exact for refetchQueries to work. Or can you give it a subset of variables and it will match similar queries.



Consider the following ....



 <Query<NotesQuery, NotesQueryVariables>
query=notesQuery
variables=
input:
notebookId: notebookContext.id,
first: 20


>
</Query>


and the following mutation:



 client
.mutate<NoteCreateOrUpdateMutation, NoteCreateOrUpdateMutationVariables>(
mutation: noteCreateOrUpdateMutation,
variables:
input:
noteId: note ? note.id : undefined,
subjectIds: noteSubjects,
notebookId: notebookContext.id,
authorId: userContext.id,
content: noteContent,
context: noteCaption,

,
refetchQueries: [

query: notesQuery,
variables: input: notebookId: notebookContext.id as NotesQueryVariables

]
)


when I do that mutation it is NOT refetching the note query with the pagination



If I add the first: 20 parameter -- it works.



I would like it to clear all noteQueries that match with the given parameters. Is that possible?










share|improve this question




























    0















    My fundimental question is do the variables for queries need to be exact for refetchQueries to work. Or can you give it a subset of variables and it will match similar queries.



    Consider the following ....



     <Query<NotesQuery, NotesQueryVariables>
    query=notesQuery
    variables=
    input:
    notebookId: notebookContext.id,
    first: 20


    >
    </Query>


    and the following mutation:



     client
    .mutate<NoteCreateOrUpdateMutation, NoteCreateOrUpdateMutationVariables>(
    mutation: noteCreateOrUpdateMutation,
    variables:
    input:
    noteId: note ? note.id : undefined,
    subjectIds: noteSubjects,
    notebookId: notebookContext.id,
    authorId: userContext.id,
    content: noteContent,
    context: noteCaption,

    ,
    refetchQueries: [

    query: notesQuery,
    variables: input: notebookId: notebookContext.id as NotesQueryVariables

    ]
    )


    when I do that mutation it is NOT refetching the note query with the pagination



    If I add the first: 20 parameter -- it works.



    I would like it to clear all noteQueries that match with the given parameters. Is that possible?










    share|improve this question
























      0












      0








      0








      My fundimental question is do the variables for queries need to be exact for refetchQueries to work. Or can you give it a subset of variables and it will match similar queries.



      Consider the following ....



       <Query<NotesQuery, NotesQueryVariables>
      query=notesQuery
      variables=
      input:
      notebookId: notebookContext.id,
      first: 20


      >
      </Query>


      and the following mutation:



       client
      .mutate<NoteCreateOrUpdateMutation, NoteCreateOrUpdateMutationVariables>(
      mutation: noteCreateOrUpdateMutation,
      variables:
      input:
      noteId: note ? note.id : undefined,
      subjectIds: noteSubjects,
      notebookId: notebookContext.id,
      authorId: userContext.id,
      content: noteContent,
      context: noteCaption,

      ,
      refetchQueries: [

      query: notesQuery,
      variables: input: notebookId: notebookContext.id as NotesQueryVariables

      ]
      )


      when I do that mutation it is NOT refetching the note query with the pagination



      If I add the first: 20 parameter -- it works.



      I would like it to clear all noteQueries that match with the given parameters. Is that possible?










      share|improve this question














      My fundimental question is do the variables for queries need to be exact for refetchQueries to work. Or can you give it a subset of variables and it will match similar queries.



      Consider the following ....



       <Query<NotesQuery, NotesQueryVariables>
      query=notesQuery
      variables=
      input:
      notebookId: notebookContext.id,
      first: 20


      >
      </Query>


      and the following mutation:



       client
      .mutate<NoteCreateOrUpdateMutation, NoteCreateOrUpdateMutationVariables>(
      mutation: noteCreateOrUpdateMutation,
      variables:
      input:
      noteId: note ? note.id : undefined,
      subjectIds: noteSubjects,
      notebookId: notebookContext.id,
      authorId: userContext.id,
      content: noteContent,
      context: noteCaption,

      ,
      refetchQueries: [

      query: notesQuery,
      variables: input: notebookId: notebookContext.id as NotesQueryVariables

      ]
      )


      when I do that mutation it is NOT refetching the note query with the pagination



      If I add the first: 20 parameter -- it works.



      I would like it to clear all noteQueries that match with the given parameters. Is that possible?







      graphql apollo apollo-client






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 19:15









      JonathanJonathan

      10.3k85082




      10.3k85082






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I believe you'll be wanting to add @connection directives to your gql definitions of notesQuery and measurementsQuery. You didn't post those, so unfortunately I can't show you exactly what that would look like for your use case.



          Anyway, the @connection directive will allow Apollo to match on notebookId for example, while ignoring the value of first.



          Unfortunately, you've bundled all your input into the object input, and I don't know how you would select just notebookId with the filter. Assuming that your gql definition looks something like this for notesQuery:



          const notesQuery = gql`
          query notes($input: InputType!)
          notes(input: $input) @connection(key: "notes", filter: ["input['notebookId']"])
          id
          ...


          `;


          ^^^ Unfortunately, that won't work because of the way that apollo-utilities/lib/storeUtils.js -> getStoreKeyName() function works. It'll just ignore the above attempt to get better resolution than an arg name, i.e. can't go beyond input. Any string in the filter array that doesn't match an arg name is silently ignored.



          Looks like you'll have to modify your schema.



          More info at: https://www.apollographql.com/docs/react/features/pagination.html#connection-directive






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306424%2fhow-to-match-queries-with-apollos-refetchquery%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I believe you'll be wanting to add @connection directives to your gql definitions of notesQuery and measurementsQuery. You didn't post those, so unfortunately I can't show you exactly what that would look like for your use case.



            Anyway, the @connection directive will allow Apollo to match on notebookId for example, while ignoring the value of first.



            Unfortunately, you've bundled all your input into the object input, and I don't know how you would select just notebookId with the filter. Assuming that your gql definition looks something like this for notesQuery:



            const notesQuery = gql`
            query notes($input: InputType!)
            notes(input: $input) @connection(key: "notes", filter: ["input['notebookId']"])
            id
            ...


            `;


            ^^^ Unfortunately, that won't work because of the way that apollo-utilities/lib/storeUtils.js -> getStoreKeyName() function works. It'll just ignore the above attempt to get better resolution than an arg name, i.e. can't go beyond input. Any string in the filter array that doesn't match an arg name is silently ignored.



            Looks like you'll have to modify your schema.



            More info at: https://www.apollographql.com/docs/react/features/pagination.html#connection-directive






            share|improve this answer



























              1














              I believe you'll be wanting to add @connection directives to your gql definitions of notesQuery and measurementsQuery. You didn't post those, so unfortunately I can't show you exactly what that would look like for your use case.



              Anyway, the @connection directive will allow Apollo to match on notebookId for example, while ignoring the value of first.



              Unfortunately, you've bundled all your input into the object input, and I don't know how you would select just notebookId with the filter. Assuming that your gql definition looks something like this for notesQuery:



              const notesQuery = gql`
              query notes($input: InputType!)
              notes(input: $input) @connection(key: "notes", filter: ["input['notebookId']"])
              id
              ...


              `;


              ^^^ Unfortunately, that won't work because of the way that apollo-utilities/lib/storeUtils.js -> getStoreKeyName() function works. It'll just ignore the above attempt to get better resolution than an arg name, i.e. can't go beyond input. Any string in the filter array that doesn't match an arg name is silently ignored.



              Looks like you'll have to modify your schema.



              More info at: https://www.apollographql.com/docs/react/features/pagination.html#connection-directive






              share|improve this answer

























                1












                1








                1







                I believe you'll be wanting to add @connection directives to your gql definitions of notesQuery and measurementsQuery. You didn't post those, so unfortunately I can't show you exactly what that would look like for your use case.



                Anyway, the @connection directive will allow Apollo to match on notebookId for example, while ignoring the value of first.



                Unfortunately, you've bundled all your input into the object input, and I don't know how you would select just notebookId with the filter. Assuming that your gql definition looks something like this for notesQuery:



                const notesQuery = gql`
                query notes($input: InputType!)
                notes(input: $input) @connection(key: "notes", filter: ["input['notebookId']"])
                id
                ...


                `;


                ^^^ Unfortunately, that won't work because of the way that apollo-utilities/lib/storeUtils.js -> getStoreKeyName() function works. It'll just ignore the above attempt to get better resolution than an arg name, i.e. can't go beyond input. Any string in the filter array that doesn't match an arg name is silently ignored.



                Looks like you'll have to modify your schema.



                More info at: https://www.apollographql.com/docs/react/features/pagination.html#connection-directive






                share|improve this answer













                I believe you'll be wanting to add @connection directives to your gql definitions of notesQuery and measurementsQuery. You didn't post those, so unfortunately I can't show you exactly what that would look like for your use case.



                Anyway, the @connection directive will allow Apollo to match on notebookId for example, while ignoring the value of first.



                Unfortunately, you've bundled all your input into the object input, and I don't know how you would select just notebookId with the filter. Assuming that your gql definition looks something like this for notesQuery:



                const notesQuery = gql`
                query notes($input: InputType!)
                notes(input: $input) @connection(key: "notes", filter: ["input['notebookId']"])
                id
                ...


                `;


                ^^^ Unfortunately, that won't work because of the way that apollo-utilities/lib/storeUtils.js -> getStoreKeyName() function works. It'll just ignore the above attempt to get better resolution than an arg name, i.e. can't go beyond input. Any string in the filter array that doesn't match an arg name is silently ignored.



                Looks like you'll have to modify your schema.



                More info at: https://www.apollographql.com/docs/react/features/pagination.html#connection-directive







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 18:33









                Paul ParkerPaul Parker

                38029




                38029





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306424%2fhow-to-match-queries-with-apollos-refetchquery%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript