-
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): Expose mutations to the gateway. #7358
feat(Apollo): Expose mutations to the gateway. #7358
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.
Reviewed 7 of 7 files at r1, 2 of 2 files at r2.
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.
Reviewable status: 6 of 9 files reviewed, 5 unresolved discussions (waiting on @abhimanyusinghgaur and @minhaj-shakeel)
graphql/e2e/common/query.go, line 455 at r3 (raw file):
func addMutationOnExtendedTypeWithIDasKeyField(t *testing.T) { addAstronautParams := &GraphQLParams{ Query: `mutation addAstronaut($id1: ID!, $missionId1: String!, $id2: ID!, $missionId2: String! ) {
Do the mission and astronaut with the specified ids already exist in this service?
graphql/resolve/query_rewriter.go, line 263 at r3 (raw file):
// } // If key field is of ID type but it is an external field,
This comment looks like it belongs in the else block.
So basically if it's not external, then we query using the uid otherwise we treat it as a string and query using eq
function.
graphql/schema/gqlschema.go, line 993 at r3 (raw file):
addFieldFilters(sch, defn, apolloServiceQuery) addAggregationResultType(sch, defn) // Don't expose queries for the @extends type to the gateway
What about all the other things like filters and such which the query uses. Should they also not be exposed?
graphql/schema/wrappers.go, line 511 at r3 (raw file):
// If key field is of ID type but it is an external field, // then it is stored in Dgraph as string type with Hash index. // So we need the predicate mapping in this case.
Can we add a dgraph schema gen test for key field which is an ID but is an external field that shows the type for it in Dgraph schema?
graphql/schema/testdata/apolloservice/output/extended-types.graphql, line 357 at r3 (raw file):
} input AstronautFilter {
If the astronaut query isn't generated then why do we have AstronautFilter and ORder.
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: 6 of 9 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur and @minhaj-shakeel)
graphql/e2e/common/query.go, line 466 at r3 (raw file):
} }`, Variables: map[string]interface{}{
Can you add a test where you add a new mission and link to an astronaut that doesn't exist yet? Does that return an error or work properly?
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 7 files at r1, 3 of 3 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @minhaj-shakeel)
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: 6 of 12 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur and @pawanrawal)
graphql/e2e/common/query.go, line 466 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Can you add a test where you add a new mission and link to an astronaut that doesn't exist yet? Does that return an error or work properly?
Done that. It creates a new object or links the object if the object with the same xid
already exists.
graphql/resolve/query_rewriter.go, line 263 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
This comment looks like it belongs in the else block.
So basically if it's not external, then we query using the uid otherwise we treat it as a string and query using
eq
function.
Yeah, shifted the comment and modified it.
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: 6 of 12 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur and @pawanrawal)
graphql/e2e/common/query.go, line 455 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Do the mission and astronaut with the specified ids already exist in this service?
No, both don't exist. If the mission exists, it will throw an error and if the Astronaut exists then it will just link the previous object the newly created mission object.
graphql/schema/gqlschema.go, line 993 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
What about all the other things like filters and such which the query uses. Should they also not be exposed?
These are being exposed. See the schemagen/apolloservice
tests.
graphql/schema/wrappers.go, line 511 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Can we add a dgraph schema gen test for key field which is an ID but is an external field that shows the type for it in Dgraph schema?
Those are already added in the federation
branch.
graphql/schema/testdata/apolloservice/output/extended-types.graphql, line 357 at r3 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
If the astronaut query isn't generated then why do we have AstronautFilter and ORder.
For AddAstronautPayload
.
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 r4.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @minhaj-shakeel)
Fixes GRAPHQL-968.
This PR does two things.
1 - It exposes the
mutations
to the apollo gateway which were earlier restricted. It exposes mutations for bothtype definitions
as well astype extensions
. Whereasqueries
for theextended types
arenot exposed
as they are resolved throughentity resolver
.2 - It adds support for add mutation on extended type having field with
ID
type as @key field. In this case the field is stored internally in the dgraph asstring
type so its value needs to be given as an argument inside the mutation.This change is