For the following schema
interface ValueMetadata {
id: ID!
createdAt: DateTime!
deletedAt: DateTime
author: Author! @hasInverse(field:values)
owner: Organization! @hasInverse(field:values)
}
type StringValue implements ValueMetadata {
data: String
}
type IntValue implements ValueMetadata {
data: Int
}
type FloatValue implements ValueMetadata {
data: Float
}
type DateTimeValue implements ValueMetadata {
data:DateTime
}
union Value = StringValue | IntValue | FloatValue | DateTimeValue
type Attribute {
name: String! @id
values: [Value!]
}
type Element {
hash: String! @id
type: String!
createdAt: DateTime!
archived: Boolean
author: Author! @hasInverse(field:elements)
owner: Organization! @hasInverse(field:elements)
attributes: [Attribute!]
}
type Organization {
id: String! @id
name: String
elements: [Element!]
values: [ValueMetadata!]
}
type Author {
id: String! @id
cn: String
sn: String
email: String!
elements: [Element!]
values: [ValueMetadata!]
}
and for one organization and one author object:
mutation AddOrganization($id: String!) {
addOrganization(input: {id: $id}) {
organization {
id
}
}
}
mutation AddAuthor($id: String!, $email: String!) {
addAuthor(input: {id: $id, email: $email}) {
author {
id
email
}
}
}
running this mutation
mutation AddElement($hash: String!,$type:String!, $createdAt: DateTime!,$author: String!, $owner: String!) {
addElement(input: {
hash:$hash,
type:$type,
createdAt: $createdAt,
author: {id:$author},
owner:{id: $owner},
attributes: [
{
name: "element_name",
values: [
{
stringValueRef:{
createdAt: $createdAt
author:{id: $author}
owner:{id: $owner}
data: "Prvy element"
}
}
]
},
{
name: "city",
values: [
{
stringValueRef:{
createdAt: $createdAt
author:{id: $author}
owner:{id: $owner}
data: "Bratislava"
}
}
]
},
{
name: "population",
values: [
{
intValueRef:{
createdAt: $createdAt
author:{id: $author}
owner:{id: $owner}
data: 1100
}
}
]
}
]
}) {
element {
hash
type
createdAt
author {
id
}
owner {
id
}
attributes {
name
values {
__typename
... on StringValue {
createdAt
author {
id
}
owner {
id
}
stringValue: data
}
... on IntValue {
createdAt
author {
id
}
owner {
id
}
intValue: data
}
}
}
}
}
}
ends with error:
"errors": [
{
"message": "mutation addElement failed because Dgraph execution failed because Some variables are used but not defined\nDefined:[Attribute11 Attribute16 Attribute4 Element2 __dgraph__0]\nUsed:[Attribute11 Attribute16 Attribute4 Author7 Element2 Organization9 __dgraph__0]\n",
"locations": [
{
"line": 19,
"column": 3
}
]
}
],
object are created with variables:
{
"id": "test",
"email": "test@test.com",
"hash": "1",
"type": "Car",
"createdAt": "2016-11-21T17:04:29.479Z",
"author": "test",
"owner": "test"
}
Is the GraphQL mutation on schema malformed or is it bug in GraphQL resolver?