feat(GraphQL):This PR adds subscriptions to custom DQL. #7385
feat(GraphQL):This PR adds subscriptions to custom DQL. #7385JatinDev543 merged 16 commits intomasterfrom
Conversation
pawanrawal
left a comment
There was a problem hiding this comment.
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
JatinDev543
left a comment
There was a problem hiding this comment.
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 tweetson 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.
pawanrawal
left a comment
There was a problem hiding this comment.
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
@customin graphql, many users requested to use subscriptions on custom DQL.We have the
@withSubscriptiondirective, 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
@withSubscriptiondirective on individual DQL queries intype Queryand those queries will be added intype subscription.For example, we have two custom DQL queries below
queryTweetsSortedByAuthorFollowersandqueryUserTweetCounts.queryUserTweetCountshave @withSubscription directive, and it will be added to subscription type and users will be able to subscribe to this query.This change is