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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현