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

add support for graphql-transport-ws #1354

Merged
merged 3 commits into from
Jun 12, 2022

Conversation

paulpdaniels
Copy link
Collaborator

Adds support for the new graphql subscription variant. Splits the handling of the protocol into a separate type so that it can be implemented in a single place rather than in the adapters + zio-http.

There is probably even more refactoring that can be done here to get a smaller LOC profile, but I got as far as the weekend would allow so figured this would be a good checkin that we can continue to enhance.

@guizmaii
Copy link
Contributor

guizmaii commented May 3, 2022

Hey @paulpdaniels,

What are these new variants? Where can I read about them, please?

@ghostdogpr
Copy link
Owner

Hey @paulpdaniels,

What are these new variants? Where can I read about them, please?

https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md was deprecated in favor of https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md

@paulpdaniels
Copy link
Collaborator Author

@frekw @ghostdogpr I made some significant changes since the last review, namely I refactored the pipeline logic so that it could more seamlessly handle detecting the protocol, and I had to rewire the websocket handler because the graphql-ws spec requires specific error codes to be issued in certain cases.

@paulpdaniels
Copy link
Collaborator Author

paulpdaniels commented May 27, 2022

Only the akka and play adapters seems to fail 🤔

@paulpdaniels paulpdaniels force-pushed the graphql-transport-ws branch 3 times, most recently from c0f37d8 to 662506b Compare May 29, 2022 09:44
@ghostdogpr
Copy link
Owner

I'm traveling this weekend and Monday but I'll take a look in the coming week!

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice!

In addition to unit tests, did you also test with a client such as Altair? Just wondering if I should do additional manual tests just to make sure there is no regression.

@paulpdaniels
Copy link
Collaborator Author

@ghostdogpr I just tried with the zio-http/akka and it works (it supports both formats simultaneously!). Http4s had what seems like a small compatibilty issue (sent back a null payload when it shouldn't), so I patched that.

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to me! Just a tiny remark but good to merge for me.

@paulpdaniels paulpdaniels merged commit abaee7a into ghostdogpr:master Jun 12, 2022
@paulpdaniels paulpdaniels deleted the graphql-transport-ws branch June 12, 2022 07:28
ghostdogpr pushed a commit that referenced this pull request Jun 20, 2022
* upgrade zio-config to 2.0.0 (#1367)

* Update http4s-blaze-server to 0.23.12 (#1368)

* Properly validate floating point numbers on input (#1370)

* Escape quotes in description strings (#1372)

Escape " with \" in normally quoted strings and """ with \""" in
triple-quoted strings.
https://spec.graphql.org/October2021/#sec-String-Value

* Improve persisted query performance by caching the document (#1371)

* improve persisted query performance by caching the document instead of the unparsed string.

* address comments

* Escape special characters in normally quoted strings (#1373)

* Correct field types for interface fields on union (#1375)

Ensure that when an interface fragment is used on a union that the
fields its selected have the correct type instead of always being
`String`.

* Coerce non-null values into lists of size one (#1376)

* Coerce non-null values into lists of size one

As per the specification, if a value passed as an input to a list type
is not a list and is not null then it should be coerced into a list of
size one.

* Make work on Scala 3

* Client auto-gen Option conflict (#1377)

* have ClientWriter print scala.Option instead of Option

* Fix replace case where Option may appear multiple times

* Add test for various returns of GQL Option and scala.Option

* run fmt

* update ClientWriterViewSpec

* SchemaWrite should also print scala.Option instead of Option

* add a scripted test with a schema containing type Option

* flatten scripted compile tests

* make helper method for safe Option string replacement

* add support for graphql-transport-ws (#1354)

* add support for graphql-transport-ws

* Set api mappings for ZIO (#1381)

Co-authored-by: Lordie <levimanga@gmail.com>
Co-authored-by: Scala Steward <43047562+scala-steward@users.noreply.github.com>
Co-authored-by: Kevin Mooney <moonkev@users.noreply.github.com>
Co-authored-by: Johannes Eriksson <johannes@stepzen.com>
Co-authored-by: Paul Daniels <paulpdaniels@gmail.com>
Co-authored-by: Mark Rudolph <mark@k8ty.app>
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

Successfully merging this pull request may close these issues.

None yet

3 participants