Skip to content
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

graphql: Return better error message if a type only contains ID field #5531

Merged
merged 4 commits into from
May 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address Abhimanyu's comments
pawanrawal committed May 28, 2020
commit 10e924d52b0b7cb6599bb4b5f0e6305a5e0e0d1c
15 changes: 14 additions & 1 deletion graphql/schema/gqlschema_test.yml
Original file line number Diff line number Diff line change
@@ -2050,7 +2050,6 @@ valid_schemas:
}
input AuthorUpdate {
id: ID!
name: String!
}

type Query {
@@ -2123,3 +2122,17 @@ valid_schemas:
f4: [String!]! @dgraph(pred: "f4")
f5: String @dgraph(pred: "X.f5")
}

-
name: "@custom directive with variable definitions in operation in graphql"
input: |
type Author {
id: ID!
age: Int!
name: String! @custom(http: {
url: "http://google.com/",
method: "POST",
graphql: "query ($id: ID!, $age: Int!) { getAuthor(id: $id, age: $age) }",
skipIntrospection: true
})
}
3 changes: 2 additions & 1 deletion graphql/schema/rules.go
Original file line number Diff line number Diff line change
@@ -529,7 +529,8 @@ func dgraphDirectiveTypeValidation(typ *ast.Definition) *gqlerror.Error {
// 2. Fields with @custom directive.
// to be a valid type. Otherwise its not possible to add objects of that type.
func nonIdFieldsCheck(typ *ast.Definition) *gqlerror.Error {
if isQueryOrMutation(typ.Name) || typ.Kind == ast.Enum || typ.Kind == ast.Interface {
if isQueryOrMutation(typ.Name) || typ.Kind == ast.Enum || typ.Kind == ast.Interface ||
typ.Kind == ast.InputObject {
return nil
}