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

Expose more of the schema in gql subscriptions #2591

Open
3 tasks done
IcanDivideBy0 opened this issue Nov 13, 2024 · 4 comments
Open
3 tasks done

Expose more of the schema in gql subscriptions #2591

IcanDivideBy0 opened this issue Nov 13, 2024 · 4 comments

Comments

@IcanDivideBy0
Copy link
Contributor

IcanDivideBy0 commented Nov 13, 2024

Prerequisites

  • Are you running the latest version(s)?
  • Have you searched the documentation for your issue?
  • Did you search for an existing issue or pull request?

Description

GraphQL subscriptions payload doesn't allow to traverse the data graph

Details

Currently, subscriptions payload only contains an id, mutation_type and _entity, the latest being a JSON field. This makes it hard to manage data on the client side and get full advantage of the apollo cache: apollo can't update the cached data automatically because of the missing __typename in _entity and we have no way to fetch relations as well. A more useful approach would be to have different payload types depending on the subscription, allowing to query deeper the entity being inserted/updated/deleted.
Another solution might be to expose the said entity under the Nodeinterface: this way the payload type is still the same for all subscriptions, but we can query the actual data & resolvers through a fragment inside the node.
Both way, apollo client cache would be correctly updated just by receiving the subscription, eliminating a lot of glue code and refetches on the client side (specially when working with paginated data)

@stwiname
Copy link
Collaborator

Its not a complete solution but this PR makes the entity type correct and it will now provide the __typename #2600

@IcanDivideBy0
Copy link
Contributor Author

Thank you ! The PR already makes it really easier to manage updates for simple cases, I'm leaving this open since from what i see nested data are always set to null but definitely a great improvement 🎉

@IcanDivideBy0
Copy link
Contributor Author

Also the switch to graphql-ws & graphiql is greatly appreciated 🙌

@IcanDivideBy0
Copy link
Contributor Author

Also, it looks like entity fields with a camelCase name are always null :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants