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;
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
add a comment |
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
add a comment |
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
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
graphql apollo apollo-client
asked Mar 22 at 19:15
JonathanJonathan
10.3k85082
10.3k85082
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Mar 23 at 18:33
Paul ParkerPaul Parker
38029
38029
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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