Skip to content

Commit

Permalink
handle extend keyword for Queries and Mutations (#7916)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhaj-shakeel committed Jun 23, 2021
1 parent 947a62b commit 4609268
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions graphql/schema/schemagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,13 @@ func NewHandler(input string, apolloServiceQuery bool) (Handler, error) {
}

// Convert All the Type Extensions into the Type Definitions with @external directive
// to maintain uniformity in the output schema
// to maintain uniformity in the output schema.
// No need to add `@extends` directive to type `Query` and `Mutation` since
// `extend type Query` is same as declaring `type Query`.
for _, ext := range doc.Extensions {
ext.Directives = append(ext.Directives, &ast.Directive{Name: "extends"})
if ext.Name != "Query" && ext.Name != "Mutation" {
ext.Directives = append(ext.Directives, &ast.Directive{Name: "extends"})
}
}
doc.Definitions = append(doc.Definitions, doc.Extensions...)
doc.Extensions = nil
Expand Down

0 comments on commit 4609268

Please sign in to comment.