hasura / hasura/graphql-engine
Mutation changes not yet committed when remote schema relationship is invoked?
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
Noticed this on Hasura 1.3.3, minimal example:
- Remote schema `remote`:
```gql
type Details {
an_interesting_detail: String
}
schema {
query: {
interesting_object_details(interesting_object_id: uuid!): Details
}
}
```
- Table exposed via Hasura `interesting_objects`:
```sql
CREATE TABLE interesting_objects (
id uuid NOT NULL PRIMARY KEY,
some_field text
);
```
- Remote schema relationship attaching `remote.interesting_object_details` to `interesting_objects.details` with the `id` mapped as parameter.
So now I send this mutation:
```gql
mutation MyMutation {
update_interesting_objects_by_pk(
pk_columns: {
id: "abc123..."
}
_set: {
some_field: "some value"
},
) {
id
some_value
details {
an_interesting_detail
}
}
}
```
The resolver in the remote schema reads from the same DB as Hasura, but it looks like it's getting an older version of the `interesting_object` without the updated value for `some_field`. I set this up locally and also added some delay in the resolver so I think it's because at the time when the remote schema is invoked the mutation transaction hasn't yet been committed. Is this expected behavior?
PS: I know there are other ways to achieve something similar using functions in Postgres, unfortunately in this case I really do need to run some custom code to generate `an_interesting_detail`.
Contributor guide
Research direction
Start with the minimal mutation and remote-schema relationship described in the issue, using the delayed resolver against the same database. Trace whether the mutation is committed before the relationship is resolved; done means the expected transaction behavior is established and the observed stale read is explained or addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgresql
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100