Skip to content

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 requested a review from OlegDokuka September 4, 2022 23:18
@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
* fix: clear buffer when allocating for custom metadata header

* test: add composite metadata tests

- encodeAndAddCustomMetadata
- encodeCustomMetadataHeader

Signed-off-by: Kevin Viglucci <[email protected]>
* feat: support optional metadata in rxjs adapter requesters

Signed-off-by: Kevin Viglucci <[email protected]>

* 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
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - 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 <[email protected]>
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 <[email protected]>
Signed-off-by: Kevin Viglucci <[email protected]>
* feat: support optional metadata in rxjs adapter requesters

Signed-off-by: Kevin Viglucci <[email protected]>

* 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
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - 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 <[email protected]>
Signed-off-by: Kevin Viglucci <[email protected]>
Signed-off-by: Kevin Viglucci <[email protected]>
@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.

@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