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

feat: apollo graphql link and server #225

Merged
merged 25 commits into from
Apr 29, 2023

Conversation

viglucci
Copy link
Member

@viglucci viglucci commented May 8, 2022

Adds experimental ApolloLink and ApolloServer implementations to support GraphQL over RSocket with Apollo GraphQL.

Motivation:

Spring recently added support for GraphQL over RSocket, and we were interested to see if we could provide similar support via rsocket-js. This addition will provide a mechanism for consuming RSocket transport using GraphQL servers via JS clients (browser etc.).

Additionally, these additions provide an interesting alternative to existing Apollo GraphQL subscription links, such as graphql-ws. Existing GraphQL subscription users could now benefit from a potentially increased number of available transport protocol options. I believe it would be beneficial for these advancements to be more broadly broadcasted and advocated for in the GraphQL community.

Modifications:

  • added rsocket-graphql-apollo-link package
  • added rsocket-graphql-apollo-server package
  • provided examples for using new packages

Result:

See above.

Related:

Open questions/items:

  • Are we improperly assuming a route will be used/required on the server?
  • Are we sending the proper metadata mime type on SETUP and request?
  • Are errors being handled according to spec?
  • Test Interop with Spring server/client.

@viglucci viglucci added the 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release label May 8, 2022
Comment on lines 114 to 124
runHttpQuery([], {
method: "POST",
options: () => {
return this.createGraphQLServerOptions(payload);
},
query,
request: new Request("/graphql", {
headers: new Headers(),
method: "POST",
}),
})
Copy link
Member Author

Choose a reason for hiding this comment

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

From what I can tell, runHttpQuery seems to be the best entry point into Apollo's logic for handling a query. This feels strange for our use case, seeing as we are not HTTP, so I'll likely reach out to Apollo and see if there is a better way to process a query that is completely divorced from HTTP concepts.

@viglucci viglucci force-pushed the feature/apollo-graphql-link-server branch from c436421 to 4748c68 Compare May 8, 2022 20:56
@viglucci
Copy link
Member Author

viglucci commented May 25, 2022

Moving this PR out of draft is pending investigating Apollo's executeOperation, as suggested here.

@viglucci viglucci marked this pull request as ready for review September 4, 2022 22:34
@viglucci viglucci changed the title (draft) feat: apollo graphl link and server feat: apollo graphl link and server Sep 4, 2022
@viglucci viglucci force-pushed the feature/apollo-graphql-link-server branch from 47455e4 to ac6ac87 Compare September 4, 2022 23:01
@viglucci
Copy link
Member Author

viglucci commented Sep 4, 2022

I will fix DCO on merge.

@viglucci viglucci changed the title feat: apollo graphl link and server feat: apollo graphql link and server Sep 5, 2022
@viglucci viglucci force-pushed the feature/apollo-graphql-link-server branch 2 times, most recently from bb1efc5 to 039d96e Compare November 2, 2022 14:47
viglucci and others added 17 commits April 26, 2023 20:15
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
* fix: clear buffer when allocating for custom metadata header

* test: add composite metadata tests

- encodeAndAddCustomMetadata
- encodeCustomMetadataHeader

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
 - rsocket-adapter-rxjs@1.0.0-alpha.2
 - rsocket-composite-metadata@1.0.0-alpha.2
 - rsocket-examples@1.0.0-alpha.2
 - rsocket-messaging@1.0.0-alpha.2

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
* feat: support optional metadata in rxjs adapter requesters

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>

* chore(release): release

 - rsocket-adapter-rxjs@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-composite-metadata@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-core@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-examples@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-messaging@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-tcp-client@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-tcp-server@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-websocket-client@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-websocket-server@1.0.0-alpha-rxjs-adapter-optional-metadata.0

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
 - rsocket-adapter-rxjs@1.0.0-alpha.3
 - rsocket-composite-metadata@1.0.0-alpha.3
 - rsocket-core@1.0.0-alpha.3
 - rsocket-examples@1.0.0-alpha.3
 - rsocket-messaging@1.0.0-alpha.3
 - rsocket-tcp-client@1.0.0-alpha.3
 - rsocket-tcp-server@1.0.0-alpha.3
 - rsocket-websocket-client@1.0.0-alpha.3
 - rsocket-websocket-server@1.0.0-alpha.3

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
unexpectedly, in the rxjs `partition` operator the index is a local variable per subscription, thus the second subscription starts indexing from 0 once again even though the element is a second one (index should be 1 in that case). Therefore, to overcome this problem the PR introduces a local variable to track the first element.

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
 - rsocket-adapter-rxjs@1.0.0-alpha.4
 - rsocket-examples@1.0.0-alpha.4

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
 - rsocket-adapter-rxjs@1.0.0-alpha.2
 - rsocket-composite-metadata@1.0.0-alpha.2
 - rsocket-examples@1.0.0-alpha.2
 - rsocket-messaging@1.0.0-alpha.2

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
* feat: support optional metadata in rxjs adapter requesters

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>

* chore(release): release

 - rsocket-adapter-rxjs@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-composite-metadata@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-core@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-examples@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-messaging@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-tcp-client@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-tcp-server@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-websocket-client@1.0.0-alpha-rxjs-adapter-optional-metadata.0
 - rsocket-websocket-server@1.0.0-alpha-rxjs-adapter-optional-metadata.0

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
@viglucci viglucci force-pushed the feature/apollo-graphql-link-server branch from d935d63 to 03439d8 Compare April 27, 2023 01:32
@viglucci
Copy link
Member Author

Rebased to fix resolve DCO check issue.

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
@viglucci viglucci merged commit e7f4f5f into 1.0.x-alpha Apr 29, 2023
@viglucci viglucci deleted the feature/apollo-graphql-link-server branch April 29, 2023 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants