question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Responses being aggressively cached, preventing mutation operations

See original GitHub issue

Issue Description

I’m seeing unexpected mutation behavior when attempting to use the simple example schema from the README. I have this in GraphQL playground:

mutation {
  createMovie(input: {
    title: "Test"
  }) {
    id
    title
  }
}

First execution worked as expected. Arango shows a new document and the GraphQL response shows the newly generated document ID.

However, attempts to run the same query a second time do NOTHING. I’ve refreshed the GraphQL playground and run again. The server console shows nothing at all.

Even worse, I removed the original document from the Arango admin and tried again. This time the Playground responded as if it had created the document, returning the same ID as before. I then went into Arango and checked. The document does NOT exist.

Is cruddl attempting to keep some type of in-memory cache that is out of sync with Arango?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Yogucommented, Sep 13, 2019

I just released 1.1.0-alpha.1, you can give it a try 😃

1reaction
Yogucommented, Sep 13, 2019

Sorry for all the trouble.

If I’m understanding you correctly, you’re suggesting the workaround is implemented on the client side.

No, it’s not a client-side fix in the sense of a HTTP client. I thought you might have exactly the same problem as described in #82, where someone used ApolloClient on the server. If you don’t do that, then your situation is a bit different.

I just switched from graphql-yoga to apollo-server in cruddl and could reproduce your problem. It occurs because apparently ApolloServer caches the parsing result of the GraphQL query.

It’s not a caching feature in cruddl I could disable (cruddl has no caching feature). I was talking about he “feature” that one GraphQL query is always translated to one ArangoDB transaction. I don’t really want to disable that because it breaks important guarantees.

Instead, I’m going to three things:

  • I’ll add the optional property ProjectOptions.getOperationIdentifier. It allows you to generate a token object that can be used to unique define an operation. If you e.g. know that each request gets executed with a fresh context object, you can just return the context object as “operation identifier”.
  • If this property is not specified, operations with only one top-level field will still work out of the box.
  • I’ll switch from graphql-yoga to ApolloServer in the example and configure it properly to use the context as operation identifier.

I’ll release an alpha version of cruddl when I implemented this so you can test.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add option to turn caching off · Issue #242 · graphql ... - GitHub
By default, the playground caches your schema and recent queries in the browser ... Responses being aggressively cached, preventing mutation ...
Read more >
Advanced topics on caching in Apollo Client
This article describes special cases and considerations when using the Apollo Client cache. Bypassing the cache. Sometimes you shouldn't use the cache for...
Read more >
Caching GraphQL Responses - Abdelrahman's Blog
Great, now our function won't aggressively cache mutations which doesn't make any sense as they will cause change to our system, also we ......
Read more >
React Query: Fetch, cache, and update server data ... - YouTube
In this video we discuss introducing React Query to a ReactJS application. React Query provides a hooks API which allows you to fetch,...
Read more >
Prevent Caching on a specific RTK Query Endpoint
Hmm. You can't really prevent caching of queries, but you could make that a mutation - by default even two mutations with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found