-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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): Add support for @provides and @requires directive. #7503
Conversation
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.
Looking good, will review fully when finished.
Reviewed 7 of 7 files at r1, 3 of 3 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @minhaj-shakeel and @pawanrawal)
graphql/schema/gqlschema.go, line 577 at r1 (raw file):
directiveLocationMap
also add a nil
entry for the new directives in this map
graphql/schema/rules.go, line 2115 at r1 (raw file):
typ.Directives.ForName(apolloKeyDirective)
stale :)
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.
Reviewable status: 7 of 10 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur and @pawanrawal)
graphql/schema/gqlschema.go, line 577 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
directiveLocationMap
also add a
nil
entry for the new directives in this map
Done.
graphql/schema/rules.go, line 2115 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
typ.Directives.ForName(apolloKeyDirective)
stale :)
Done.
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.
Reviewed 6 of 6 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @pawanrawal)
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.
Please add a detailed commit description explaining what the feature does.
Reviewed 5 of 7 files at r1, 2 of 3 files at r2, 6 of 6 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @minhaj-shakeel)
graphql/schema/gqlschema.go, line 1611 at r3 (raw file):
// Returns true if the field is of type which can be summed. Eg: int, int64, float func isSummable(fld *ast.FieldDefinition, defn *ast.Definition, providesTypeMap map[string]bool) bool { if hasExternal(fld) && !isKeyField(fld, defn) && !providesTypeMap[fld.Name] {
can we define an fn for this as it is being used at multiple places
graphql/schema/gqlschema.go, line 2224 at r3 (raw file):
// Ignore Fields with @external directives and excluding those which are present // as an argument in @key directive if hasExternal(fld) && !isKeyField(fld, defn) && !providesTypeMap[fld.Name] {
use the fn defined above
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.
Reviewable status: 12 of 14 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur and @pawanrawal)
graphql/schema/gqlschema.go, line 1611 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
can we define an fn for this as it is being used at multiple places
Done.
graphql/schema/gqlschema.go, line 2224 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
use the fn defined above
Done.
Fixes GRAPHQL-1053.
This PR adds support for @provides and @requires directive for Apollo federation according to the [federation specs]
@provides
@provides directive is used on a field that tells the Gateway to return a specific fieldSet from the base type while fetching the field. For example:
while fetching
Review.product
from thereviews
service, and if thename
orprice
is also queried, the Gateway will fetch these from thereview
service itself. This means that thereview
service also resolves these fields, even though both fields are @external.@requires
@requires field is used on a field to annotate the fieldSet of the base type. It is used to develop a query plan where the required fields may not be needed by the client, but the service may need additional information from other services. For example:
when the Gateway fetches
user.reviews
from thereview
service, the Gateway will provideuser.email
from theUser
service and provide it as an argument to the_entities
query.(https://www.apollographql.com/docs/federation/federation-spec/).
This change is