-
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
fix(GraphQL): fix introspection completion bug #6385
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
query { | ||
__schema { | ||
__typename | ||
queryType { | ||
name | ||
__typename | ||
} | ||
mutationType { | ||
name | ||
__typename | ||
} | ||
subscriptionType { | ||
name | ||
__typename | ||
} | ||
types { | ||
...FullType | ||
} | ||
directives { | ||
__typename | ||
name | ||
locations | ||
args { | ||
...InputValue | ||
} | ||
} | ||
} | ||
} | ||
fragment FullType on __Type { | ||
kind | ||
name | ||
fields(includeDeprecated: true) { | ||
__typename | ||
name | ||
args { | ||
...InputValue | ||
__typename | ||
} | ||
type { | ||
...TypeRef | ||
__typename | ||
} | ||
isDeprecated | ||
deprecationReason | ||
} | ||
inputFields { | ||
...InputValue | ||
__typename | ||
} | ||
interfaces { | ||
...TypeRef | ||
__typename | ||
} | ||
enumValues(includeDeprecated: true) { | ||
name | ||
isDeprecated | ||
deprecationReason | ||
__typename | ||
} | ||
possibleTypes { | ||
...TypeRef | ||
__typename | ||
} | ||
__typename | ||
} | ||
fragment InputValue on __InputValue { | ||
__typename | ||
name | ||
type { | ||
...TypeRef | ||
} | ||
defaultValue | ||
} | ||
fragment TypeRef on __Type { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -673,7 +673,15 @@ func (f *field) DgraphAlias() string { | |
// if this field is repeated, then it should be aliased using its dgraph predicate which will be | ||
// unique across repeated fields | ||
if f.op.inSchema.repeatedFieldNames[f.Name()] { | ||
return f.DgraphPredicate() | ||
dgraphAlias := f.DgraphPredicate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could have been simplified by appending the if below to the if above in this block with an and condition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment about why didn't do it, because it is a performance-critical function. |
||
// there won't be any dgraph predicate for fields in introspection queries, as they are not | ||
// stored in dgraph. So we identify those fields using this condition, and just let the | ||
// field name get returned for introspection query fields, because the raw data response is | ||
// prepared for them using only the field name, so that is what should be used to pick them | ||
// back up from that raw data response before completion is performed. | ||
if dgraphAlias != "" { | ||
return dgraphAlias | ||
} | ||
} | ||
// if not repeated, alias it using its name | ||
return f.Name() | ||
|
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.
Could we have this file at one place and reference it from everywhere else? I thought we already had it somewhere else too.
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.
made it reusable