...

Text file src/github.com/vektah/gqlparser/validator/imported/spec/KnownDirectives.spec.yml

Documentation: github.com/vektah/gqlparser/validator/imported/spec

     1- name: with no directives
     2  rule: KnownDirectives
     3  schema: 0
     4  query: |2-
     5          
     6          query Foo {
     7            name
     8            ...Frag
     9          }
    10          
    11          fragment Frag on Dog {
    12            name
    13          }
    14          
    15  errors: []
    16- name: with known directives
    17  rule: KnownDirectives
    18  schema: 0
    19  query: |2-
    20          
    21          {
    22            dog @include(if: true) {
    23              name
    24            }
    25            human @skip(if: false) {
    26              name
    27            }
    28          }
    29          
    30  errors: []
    31- name: with unknown directive
    32  rule: KnownDirectives
    33  schema: 0
    34  query: |2-
    35          
    36          {
    37            dog @unknown(directive: "value") {
    38              name
    39            }
    40          }
    41          
    42  errors:
    43    - message: Unknown directive "unknown".
    44      locations:
    45        - {line: 3, column: 13}
    46- name: with many unknown directives
    47  rule: KnownDirectives
    48  schema: 0
    49  query: |2-
    50          
    51          {
    52            dog @unknown(directive: "value") {
    53              name
    54            }
    55            human @unknown(directive: "value") {
    56              name
    57              pets @unknown(directive: "value") {
    58                name
    59              }
    60            }
    61          }
    62          
    63  errors:
    64    - message: Unknown directive "unknown".
    65      locations:
    66        - {line: 3, column: 13}
    67    - message: Unknown directive "unknown".
    68      locations:
    69        - {line: 6, column: 15}
    70    - message: Unknown directive "unknown".
    71      locations:
    72        - {line: 8, column: 16}
    73- name: with well placed directives
    74  rule: KnownDirectives
    75  schema: 0
    76  query: |2-
    77          
    78          query Foo @onQuery {
    79            name @include(if: true)
    80            ...Frag @include(if: true)
    81            skippedField @skip(if: true)
    82            ...SkippedFrag @skip(if: true)
    83          }
    84          
    85          mutation Bar @onMutation {
    86            someField
    87          }
    88          
    89  errors: []
    90- name: with misplaced directives
    91  rule: KnownDirectives
    92  schema: 0
    93  query: |2-
    94          
    95          query Foo @include(if: true) {
    96            name @onQuery
    97            ...Frag @onQuery
    98          }
    99          
   100          mutation Bar @onQuery {
   101            someField
   102          }
   103          
   104  errors:
   105    - message: Directive "include" may not be used on QUERY.
   106      locations:
   107        - {line: 2, column: 17}
   108    - message: Directive "onQuery" may not be used on FIELD.
   109      locations:
   110        - {line: 3, column: 14}
   111    - message: Directive "onQuery" may not be used on FRAGMENT_SPREAD.
   112      locations:
   113        - {line: 4, column: 17}
   114    - message: Directive "onQuery" may not be used on MUTATION.
   115      locations:
   116        - {line: 7, column: 20}
   117- name: within schema language/with well placed directives
   118  rule: KnownDirectives
   119  schema: 0
   120  query: |2-
   121            
   122            type MyObj implements MyInterface @onObject {
   123              myField(myArg: Int @onArgumentDefinition): String @onFieldDefinition
   124            }
   125            
   126            extend type MyObj @onObject
   127            
   128            scalar MyScalar @onScalar
   129            
   130            extend scalar MyScalar @onScalar
   131            
   132            interface MyInterface @onInterface {
   133              myField(myArg: Int @onArgumentDefinition): String @onFieldDefinition
   134            }
   135            
   136            extend interface MyInterface @onInterface
   137            
   138            union MyUnion @onUnion = MyObj | Other
   139            
   140            extend union MyUnion @onUnion
   141            
   142            enum MyEnum @onEnum {
   143              MY_VALUE @onEnumValue
   144            }
   145            
   146            extend enum MyEnum @onEnum
   147            
   148            input MyInput @onInputObject {
   149              myField: Int @onInputFieldDefinition
   150            }
   151            
   152            extend input MyInput @onInputObject
   153            
   154            schema @onSchema {
   155              query: MyQuery
   156            }
   157            
   158            extend schema @onSchema
   159            
   160  errors: []
   161- name: within schema language/with misplaced directives
   162  rule: KnownDirectives
   163  schema: 0
   164  query: |2-
   165            
   166            type MyObj implements MyInterface @onInterface {
   167              myField(myArg: Int @onInputFieldDefinition): String @onInputFieldDefinition
   168            }
   169            
   170            scalar MyScalar @onEnum
   171            
   172            interface MyInterface @onObject {
   173              myField(myArg: Int @onInputFieldDefinition): String @onInputFieldDefinition
   174            }
   175            
   176            union MyUnion @onEnumValue = MyObj | Other
   177            
   178            enum MyEnum @onScalar {
   179              MY_VALUE @onUnion
   180            }
   181            
   182            input MyInput @onEnum {
   183              myField: Int @onArgumentDefinition
   184            }
   185            
   186            schema @onObject {
   187              query: MyQuery
   188            }
   189            
   190            extend schema @onObject
   191            
   192  errors:
   193    - message: Directive "onInterface" may not be used on OBJECT.
   194      locations:
   195        - {line: 2, column: 43}
   196    - message: Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.
   197      locations:
   198        - {line: 3, column: 30}
   199    - message: Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.
   200      locations:
   201        - {line: 3, column: 63}
   202    - message: Directive "onEnum" may not be used on SCALAR.
   203      locations:
   204        - {line: 6, column: 25}
   205    - message: Directive "onObject" may not be used on INTERFACE.
   206      locations:
   207        - {line: 8, column: 31}
   208    - message: Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.
   209      locations:
   210        - {line: 9, column: 30}
   211    - message: Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.
   212      locations:
   213        - {line: 9, column: 63}
   214    - message: Directive "onEnumValue" may not be used on UNION.
   215      locations:
   216        - {line: 12, column: 23}
   217    - message: Directive "onScalar" may not be used on ENUM.
   218      locations:
   219        - {line: 14, column: 21}
   220    - message: Directive "onUnion" may not be used on ENUM_VALUE.
   221      locations:
   222        - {line: 15, column: 20}
   223    - message: Directive "onEnum" may not be used on INPUT_OBJECT.
   224      locations:
   225        - {line: 18, column: 23}
   226    - message: Directive "onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.
   227      locations:
   228        - {line: 19, column: 24}
   229    - message: Directive "onObject" may not be used on SCHEMA.
   230      locations:
   231        - {line: 22, column: 16}
   232    - message: Directive "onObject" may not be used on SCHEMA.
   233      locations:
   234        - {line: 26, column: 23}

View as plain text