graphql-engine
graphql-engine copied to clipboard
graphql transactions over websockets
Requires https://github.com/hasura/pg-client-hs/pull/15 to be merged.
TODO:-
- ~Request Id in query error~
- ~tx isolation via headers~
- ~error -> query_error~
- ~encode pre-exec errors differently~
- ~cors check~
- ~tests~ basic tests
- ~restrict actions~
Description
The protocol documented here.
Support executing GraphQL queries in a transaction over a WebSocket session. Remote schema queries, Subscriptions and actions are not supported.
Affected components
- [x] Server
- [ ] Console
- [ ] CLI
- [ ] Docs
- [ ] Community Content
- [ ] Build System
- [x] Tests
- [ ] Other (list it)
Related Issues
NA
Solution and Design
The onConn
, onMessage
and onClose
functions in Hasura.GraphQL.Transport.WebSocket
module are extended to support graphql-tx
websocket subprotocol.
Modules related to websocket are refactored. Queries related:-
-
Hasura.GraphQL.Transport.WebSocket.Queries.Handlers
-
Hasura.GraphQL.Transport.WebSocket.Queries.Types
-
Hasura.GraphQL.Transport.WebSocket.Queries.Protocol
Transaction related:-
-
Hasura.GraphQL.Transport.WebSocket.Transaction.Handlers
-
Hasura.GraphQL.Transport.WebSocket.Transaction.Types
-
Hasura.GraphQL.Transport.WebSocket.Transaction.Protocol
Server checklist
Catalog upgrade
Does this PR change Hasura Catalog version?
- [x] No
- [ ] Yes
Metadata
Does this PR add a new Metadata feature?
- [x] No
- [ ] Yes
GraphQL
- [x] No new GraphQL schema is generated
- [ ] New GraphQL schema is being generated:
Breaking changes
- [x] No Breaking changes
- [ ] There are breaking changes:
Steps to test and verify
Limitations, known bugs & workarounds
Deploy preview for hasura-docs ready!
Built with commit 3b6f2e17a0ddf6afd6511b7102182ade88978a9d
https://deploy-preview-3557--hasura-docs.netlify.com
Review app for commit 26bd618d02aebb00c1c0fd98d49bc7e00ec6f2ca deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-26bd618d
Review app for commit 62cf948a77d505002b6b23f7ed219adaa2b45bcd deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-62cf948a
@rakeshkky what is the request_id
in the execute
operation?
Review app for commit 2d6ee4b77923373196202386254adf9646b85488 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-2d6ee4b7
Review app for commit 40e49369702593c07a29ae2921f4fef3043d0e73 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-40e49369
Review app for commit 6e59b5b1b5fb402725617e37c471b6df08d1c521 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-6e59b5b1
Review app for commit bd35015e66a8a42a62057699dd252307aedeb8f5 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-bd35015e
Review app for commit af0beaaaadb89acdd8401fcbf3eb97ac6a8f02cd deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-af0beaaa
Review app for commit fe45fc91f7fd82b98993b81e3788464d2b2bc5be deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-fe45fc91
Review app for commit 3d391aa793e06ecb520a5d563d0d5be683d53d55 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-3d391aa7
Review app for commit 3b6f2e17a0ddf6afd6511b7102182ade88978a9d deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-3b6f2e17
Deploy preview for hasura-docs ready!
Built with commit da4d7d0f801e1f987b601c994e59fcc485b5b265
https://deploy-preview-3557--hasura-docs.netlify.com
@rakeshkky @coco98 Could I have some more context on this? Is there a feature request somewhere for this change that has informed the protocol design? Have we talked to users about whether or not this protocol makes sense?
@lexi-lambda For actions (see #3042), we need transactions to perform multiple queries in a webhook handler. Thus we can rollback the all mutations made by handler on any exception.
The protocol design is documented here and it is partly inspired from apollo's websocket protocol which the graphql-engine implements for graphql queries over websocket.
Review app for commit 3038341e7d267912a85edb32459f0cc2a5bff083 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-3038341e
Review app for commit 950e5f41fd8db4e34f3b5eeae474cbfd3250dd65 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-950e5f41
Review app for commit 3f2be28a8b3e027122a03535b9eb96b75ee342e8 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-3f2be28a
Review app for commit 826c419cd65b7fe8e5b33b70bd09a6070603302e deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-826c419c
Review app for commit da4d7d0f801e1f987b601c994e59fcc485b5b265 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-da4d7d0f
Review app for commit 2e391cf9d23a9e0719fdf0e521ad178c0013aba6 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3557-2e391cf9
Sample client + code: https://gist.github.com/gautambt/b852e3052c6c6f02fcd52415ce3937b1
Any movement on this? Would love this feature.
Any updates on this?
Any updates on this?
Any progress on this?
Hey @rakeshkky Do you or the Hasura team have any updates on this feature?
Thank you for this PR! We are sorry we took so long to review. The entire subscription code/architecture is changed, I will close this PR to avoid conflicts in the server code.
Feel free to open a fresh PR for further review.