github.com/dgraph-io/dgraph@v1.2.8/graphql/resolve/validate_mutation_test.yaml (about)

     1  -
     2    name: "Add mutation with object instead of an array"
     3    gqlmutation: |
     4      mutation addAuthor($auth: AddAuthorInput!) {
     5        addAuthor(input: $auth) {
     6          author {
     7            name
     8          }
     9        }
    10      }
    11    gqlvariables: |
    12      { "auth":
    13        { "name": "A.N. Author",
    14          "country": { "id": "HI!" },
    15          "posts": []
    16        }
    17      }
    18    explanation: "Add mutation expects an array instead of an object"
    19    validationerror:
    20      { "message":
    21              "input:2: Variable type provided AddAuthorInput! is incompatible with expected
    22              type [AddAuthorInput!]!\ninput:2: Variable \"$auth\" of type \"AddAuthorInput!\"
    23              used in position expecting type \"[AddAuthorInput!]!\".\n" }
    24  
    25  
    26  -
    27    name: "Add mutation with invalid object"
    28    gqlmutation: |
    29      mutation addAuthor($auth: AddAuthorInput!) {
    30        addAuthor(input: [$auth]) {
    31          author {
    32            name
    33          }
    34        }
    35      }
    36    gqlvariables: |
    37      { "auth":
    38        { "posts": []
    39        }
    40      }
    41    explanation: "Name is a required field here and all the elements provided
    42         should have one"
    43    validationerror:
    44      { "message":
    45        "input: variable.auth.name must be defined" }
    46  
    47  -
    48    name: "Add multiple mutation with invalid object"
    49    gqlmutation: |
    50      mutation addAuthor($auth: [AddAuthorInput!]!) {
    51        addAuthor(input: $auth) {
    52          author {
    53            name
    54          }
    55        }
    56      }
    57    gqlvariables: |
    58      { "auth": [
    59        { "name": "A.N. Author",
    60          "posts": []
    61        },
    62        { "posts": []
    63        }]
    64      }
    65    explanation: "Name is a required field and all the elements provided
    66        should have one"
    67    validationerror:
    68      { "message":
    69        "input: variable.auth[1].name must be defined" }