-
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(GraphQL): Disallow DQL schema changes for predicates used in GraphQL schema (DGRAPH-3245) #7742
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.
nice changes
Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @abhimanyusinghgaur, @manishrjain, and @vvbalaji-dgraph)
edgraph/server.go, line 563 at r1 (raw file):
// convert the existing GraphQL schema to a DQL schema handler, err := gqlSchema.NewHandler(existingGQLSch, false)
We can't get all of this from the schema that we have in memory?
edgraph/server.go, line 579 at r1 (raw file):
gqlReservedPreds := make(map[string]*pb.SchemaUpdate) gqlReservedTypes := make(map[string]*pb.TypeUpdate) for _, pred := range gqlReservedDgSch.Preds {
I suppose this uses the @dgraph
directive pred name where one is available?
edgraph/server.go, line 605 at r1 (raw file):
dgType = "[" + dgType + "]" } return errors.Errorf("type mismatch for GraphQL predicate %s. want: %s, got: %s",
What's the exact message that's returned to the user? Is it clear that this predicate is being used by the GraphQL API and the schema change is incompatible with the GraphQL def? We should make sure that the error is clear to the user here.
edgraph/server.go, line 622 at r1 (raw file):
} } // if gqlSchema had @reverse, then dqlSchema must have it. dqlSchema can't remove @reverse.
Can gqlSchema
even have reverse? Would that be for predicates added before a GraphQL API was formed?
edgraph/server.go, line 629 at r1 (raw file):
x.ParseAttr(gqlPred.Predicate)) } // if gqlSchema had @count, then dqlSchema must have it. dqlSchema can't remove @count.
I thought that dqlSchema could change @count
and reverse
but not other indexes?
edgraph/server.go, line 662 at r1 (raw file):
} // check that all the fields of the gqlType must be present in the dqlType
Interesting, this is useful for delete I guess?
edgraph/server.go, line 665 at r1 (raw file):
for _, f := range gqlType.Fields { if !dqlFields[f.Predicate] { return errors.Errorf("missing field %s in GraphQL type %s",
Just make sure the error messages returned in all the cases are easy to understand for the user.
graphql/e2e/schema/schema_test.go, line 739 at r1 (raw file):
Person.relative: uid . `, }).Error(), "type mismatch for GraphQL predicate Person.age. want: int, got: float")
Cannot alter predicate Person.age, type definition is incompatible with what is expected by the GraphQL API for type: Person, field: age, want: int, got: float
Is the above possible?
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: 0 of 2 files reviewed, 8 unresolved discussions (waiting on @manishrjain, @pawanrawal, and @vvbalaji-dgraph)
edgraph/server.go, line 563 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
We can't get all of this from the schema that we have in memory?
As per lazy-loading, we don't want to keep all schemas in memory. So, fetching from disk as required.
edgraph/server.go, line 579 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
I suppose this uses the
@dgraph
directive pred name where one is available?
yeah!
edgraph/server.go, line 605 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
What's the exact message that's returned to the user? Is it clear that this predicate is being used by the GraphQL API and the schema change is incompatible with the GraphQL def? We should make sure that the error is clear to the user here.
Done.
edgraph/server.go, line 622 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Can
gqlSchema
even have reverse? Would that be for predicates added before a GraphQL API was formed?
yeah! for cases like @dgraph(pred: "~Person.follows")
, it adds @reverse
.
edgraph/server.go, line 629 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
I thought that dqlSchema could change
@count
andreverse
but not other indexes?
yeah! dqlSchema can change @count
and @reverse
, but only if they were not added by GraphQL.
edgraph/server.go, line 662 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Interesting, this is useful for delete I guess?
yeah! useful for delete mutation.
edgraph/server.go, line 665 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Just make sure the error messages returned in all the cases are easy to understand for the user.
Done.
graphql/e2e/schema/schema_test.go, line 739 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Cannot alter predicate Person.age, type definition is incompatible with what is expected by the GraphQL API for type: Person, field: age, want: int, got: float
Is the above possible?
Done.
See Discuss Issue for more details.
This change is