graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

graphql transactions over websockets

Open rakeshkky opened this issue 4 years ago • 27 comments

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

rakeshkky avatar Dec 17 '19 16:12 rakeshkky

Deploy preview for hasura-docs ready!

Built with commit 3b6f2e17a0ddf6afd6511b7102182ade88978a9d

https://deploy-preview-3557--hasura-docs.netlify.com

netlify[bot] avatar Dec 17 '19 16:12 netlify[bot]

Review app for commit 26bd618d02aebb00c1c0fd98d49bc7e00ec6f2ca deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-26bd618d

hasura-bot avatar Dec 17 '19 17:12 hasura-bot

Review app for commit 62cf948a77d505002b6b23f7ed219adaa2b45bcd deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-62cf948a

hasura-bot avatar Dec 18 '19 06:12 hasura-bot

@rakeshkky what is the request_id in the execute operation?

coco98 avatar Dec 18 '19 07:12 coco98

Review app for commit 2d6ee4b77923373196202386254adf9646b85488 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-2d6ee4b7

hasura-bot avatar Dec 18 '19 13:12 hasura-bot

Review app for commit 40e49369702593c07a29ae2921f4fef3043d0e73 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-40e49369

hasura-bot avatar Jan 13 '20 08:01 hasura-bot

Review app for commit 6e59b5b1b5fb402725617e37c471b6df08d1c521 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-6e59b5b1

hasura-bot avatar Jan 13 '20 14:01 hasura-bot

Review app for commit bd35015e66a8a42a62057699dd252307aedeb8f5 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-bd35015e

hasura-bot avatar Jan 14 '20 12:01 hasura-bot

Review app for commit af0beaaaadb89acdd8401fcbf3eb97ac6a8f02cd deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-af0beaaa

hasura-bot avatar Jan 15 '20 08:01 hasura-bot

Review app for commit fe45fc91f7fd82b98993b81e3788464d2b2bc5be deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-fe45fc91

hasura-bot avatar Jan 15 '20 12:01 hasura-bot

Review app for commit 3d391aa793e06ecb520a5d563d0d5be683d53d55 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-3d391aa7

hasura-bot avatar Jan 15 '20 14:01 hasura-bot

Review app for commit 3b6f2e17a0ddf6afd6511b7102182ade88978a9d deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-3b6f2e17

hasura-bot avatar Jan 15 '20 16:01 hasura-bot

Deploy preview for hasura-docs ready!

Built with commit da4d7d0f801e1f987b601c994e59fcc485b5b265

https://deploy-preview-3557--hasura-docs.netlify.com

netlify[bot] avatar Jan 21 '20 10:01 netlify[bot]

@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 avatar Jan 21 '20 22:01 lexi-lambda

@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.

rakeshkky avatar Jan 22 '20 06:01 rakeshkky

Review app for commit 3038341e7d267912a85edb32459f0cc2a5bff083 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-3038341e

hasura-bot avatar Jan 23 '20 08:01 hasura-bot

Review app for commit 950e5f41fd8db4e34f3b5eeae474cbfd3250dd65 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-950e5f41

hasura-bot avatar Mar 20 '20 08:03 hasura-bot

Review app for commit 3f2be28a8b3e027122a03535b9eb96b75ee342e8 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-3f2be28a

hasura-bot avatar Mar 31 '20 15:03 hasura-bot

Review app for commit 826c419cd65b7fe8e5b33b70bd09a6070603302e deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-826c419c

hasura-bot avatar Apr 01 '20 11:04 hasura-bot

Review app for commit da4d7d0f801e1f987b601c994e59fcc485b5b265 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-da4d7d0f

hasura-bot avatar Apr 03 '20 07:04 hasura-bot

Review app for commit 2e391cf9d23a9e0719fdf0e521ad178c0013aba6 deployed to Heroku: https://hge-ci-pull-3557.herokuapp.com Docker image for server: hasura/graphql-engine:pull3557-2e391cf9

hasura-bot avatar Apr 03 '20 07:04 hasura-bot

Sample client + code: https://gist.github.com/gautambt/b852e3052c6c6f02fcd52415ce3937b1

tirumaraiselvan avatar Aug 03 '20 06:08 tirumaraiselvan

Any movement on this? Would love this feature.

jchiatt avatar Jul 01 '21 04:07 jchiatt

Any updates on this?

perrosnk avatar Jul 19 '21 16:07 perrosnk

Any updates on this?

willyxiao avatar Sep 21 '21 18:09 willyxiao

Any progress on this?

aaronhayes avatar Jan 15 '22 02:01 aaronhayes

Hey @rakeshkky Do you or the Hasura team have any updates on this feature?

Omnean avatar Sep 12 '22 14:09 Omnean