-
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):This PR adds subscriptions to custom DQL. #7385
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 54 files at r1.
Reviewable status: 7 of 54 files reviewed, 5 unresolved discussions (waiting on @danielmai and @jatindevdg)
graphql/e2e/schema/generatedSchema.graphql, line 183 at r1 (raw file):
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id on FIELD_DEFINITION directive @withSubscription on OBJECT | INTERFACE | FIELD_DEFINITION
We should have a validation that this is only allowed on fields within Query and not fields within types.
graphql/e2e/subscription/subscription_test.go, line 75 at r1 (raw file):
# Dgraph.Authorization {"VerificationKey":"secret","Header":"Authorization","Namespace":"https://dgraph.io","Algo":"HS256"} ` schCustomDQL = `type Tweets {
have type tweets
on the next line
graphql/schema/gqlschema.go, line 850 at r1 (raw file):
for _, q := range defn.Fields { customDir := q.Directives.ForName(customDirective) subsDir := q.Directives.ForName(subscriptionDirective)
what happens if there is a withSubscription and its not a DQL query, is that an error?
graphql/schema/gqlschema.go, line 852 at r1 (raw file):
subsDir := q.Directives.ForName(subscriptionDirective) if customDir != nil { if !(customDir.Arguments.ForName("dql") == nil || subsDir == nil) {
(if subsDir != nil && dql != nil) is more readable
graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql, line 18 at r1 (raw file):
type Query { queryTweetsSortedByAuthorFollowers(search: String!): [Tweets] @custom(dql: """
not useful for this test, please remove as this is probably already tested in another file
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: 3 of 56 files reviewed, 5 unresolved discussions (waiting on @danielmai and @pawanrawal)
graphql/e2e/schema/generatedSchema.graphql, line 183 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
We should have a validation that this is only allowed on fields within Query and not fields within types.
done.
graphql/e2e/subscription/subscription_test.go, line 75 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
have
type tweets
on the next line
done.
graphql/schema/gqlschema.go, line 850 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
what happens if there is a withSubscription and its not a DQL query, is that an error?
added validation error for that case.
graphql/schema/gqlschema.go, line 852 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
(if subsDir != nil && dql != nil) is more readable
changed.
graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql, line 18 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
not useful for this test, please remove as this is probably already tested in another file
removed.
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 1 of 11 files at r2.
Reviewable status: 4 of 57 files reviewed, all discussions resolved (waiting on @danielmai and @pawanrawal)
Fixes GRAPHQL-993
As of now, we only allow subscriptions on GraphQL queries. As we can use DQL through
@custom
in graphql, many users requested to use subscriptions on custom DQL.We have the
@withSubscription
directive, that we use on GraphQL types to generate subscriptions on queries for that type.We are now extending this directive to DQL queries in custom queries. Users can specify
@withSubscription
directive on individual DQL queries intype Query
and those queries will be added intype subscription
.For example, we have two custom DQL queries below
queryTweetsSortedByAuthorFollowers
andqueryUserTweetCounts
.queryUserTweetCounts
have @withSubscription directive, and it will be added to subscription type and users will be able to subscribe to this query.This change is