Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutations not invalidating cache when sending a mutation with data containing a hashtag (#) #2290

Closed
FPDK opened this issue Feb 19, 2022 · 2 comments · Fixed by #2295
Closed
Labels
bug 🐛 Oh no! A bug or unintented behaviour.

Comments

@FPDK
Copy link

FPDK commented Feb 19, 2022

Hi,

This issue seems to be related to #195

If I send this mutation the first time, everything is OK:

mutation updateItem {
    updateItem(input: {
        id: "path/to/1",
        name: "URQL example #1",
        comment:"Hello world"
    }) {
        item {
            id
        }
    }}

But if I then change only the name to URQL example#2 and send the mutation again, then the old mutation is sent.

The new mutation shows up if I console.log my mutation before calling my URQL client:

console.log(mutation) // This outputs the new mutation (changed name)
client
            .mutation(mutation)
            .toPromise()
            .then((response) => {
...
})

A new mutation is sent if:

  • Another property is changed as well (name: "URQL example #2", comment: "Hello github")
  • The content before the hashtag is changed (name: "Something before the hashtag#and after")

I have set up my client as follows:

const client = createClient({
    url: API_GRAPHQL_URL,
    requestPolicy: "network-only",
    exchanges: [
        devtoolsExchange,
        dedupExchange,
        fetchExchange,
    ],
    fetchOptions: () => {
        return {
            credentials: "include",
            headers: {},
            cache: "no-cache",
        }
    },
})

My temporary fix is to always change another property in the mutation (append a space to the "comment" in the above case).

I am using [email protected] on Typescript [email protected].

@FPDK FPDK added the bug 🐛 Oh no! A bug or unintented behaviour. label Feb 19, 2022
@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Feb 19, 2022

Mind making a reproduction? The client you linked is not using a cache so that could be the issue 😅

EDIT: Oh I realise now you are inlining your variables 😅 to avoid having this happen we'd advise you to use interpolation

@kitten
Copy link
Member

kitten commented Feb 21, 2022

This is technically a duplicate of #1960 and we weren't too inclined to make this more complicated when this is more of an uncommon behaviour due to the lack of variables in the query. It also leads to degraded behaviour rather than straight up breakage, but we could update the regex here too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Oh no! A bug or unintented behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants