-
Notifications
You must be signed in to change notification settings - Fork 357
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: CompletableFuture in FederatedTypeResolver, standardize entities resolver with other subgraph implementations #1514
feat: CompletableFuture in FederatedTypeResolver, standardize entities resolver with other subgraph implementations #1514
Conversation
@@ -124,6 +124,19 @@ data class User( | |||
@ExternalDirective val name: String | |||
) | |||
|
|||
/* | |||
type Author { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the code the type is actually
type Author @extends @key(fields: "authorId") {
authorId: Int! @external
name: String: @external
If both fields are external -> should it be @key(fields: "authorId", resolvable: false)
? or should there be at least a single local field?
data += null | ||
errors += result | ||
} else { | ||
data += result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should else also keep track of errors in the list?
📝 Description
With the idea of proving support for returning a
CompletableFuture
inFederatedTypeResolver
and match other subgraphs implementations a new sealed interface is added
this will be the basic interface of 2 interfaces
FederatedTypeResolver
is renamed toFederatedTypeSuspendResolver
, with support of suspendable function to be executed in a coroutineFederatedTypePromiseResolver
that will provide support to return aCompletableFuture
allowing compatibility with aDataLoader
Clients will have the freedom to decided which interface to use for their resolvers and
graphql-kotlin
will be smart enough to decide how to execute them.The execution logic will be capable of executing suspend resolvers or promise resolvers concurrently, specially useful if you have support for data loaders for only certain entities
example representations for multiple types, request to
_entities
fieldUserResolver
implementingFederatedTypeResolver
PromiseResolver
implementingFederatedTypePromiseResolver
This is going to be a breaking change as it changes the signature of the current
FederatedTypeResolver
by simplifying the logic, before it was providing a list of representations, and now it will provide a representation (internally graphql-kotlin will ensure the ordering).All this with the effort of matching other subgraph implementations like Apollo Server
https://www.apollographql.com/docs/federation/api/apollo-subgraph/#__resolvereference
graphql-kotlin
apollo-server
A couple of tests simulating async operations and delays were added to ensure ordering is properly maintained
🔗 Related Issues
#1506