...

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

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

     1- name: all variables defined
     2  rule: NoUndefinedVariables
     3  schema: 0
     4  query: |2-
     5          
     6          query Foo($a: String, $b: String, $c: String) {
     7            field(a: $a, b: $b, c: $c)
     8          }
     9          
    10  errors: []
    11- name: all variables deeply defined
    12  rule: NoUndefinedVariables
    13  schema: 0
    14  query: |2-
    15          
    16          query Foo($a: String, $b: String, $c: String) {
    17            field(a: $a) {
    18              field(b: $b) {
    19                field(c: $c)
    20              }
    21            }
    22          }
    23          
    24  errors: []
    25- name: all variables deeply in inline fragments defined
    26  rule: NoUndefinedVariables
    27  schema: 0
    28  query: |2-
    29          
    30          query Foo($a: String, $b: String, $c: String) {
    31            ... on Type {
    32              field(a: $a) {
    33                field(b: $b) {
    34                  ... on Type {
    35                    field(c: $c)
    36                  }
    37                }
    38              }
    39            }
    40          }
    41          
    42  errors: []
    43- name: all variables in fragments deeply defined
    44  rule: NoUndefinedVariables
    45  schema: 0
    46  query: |2-
    47          
    48          query Foo($a: String, $b: String, $c: String) {
    49            ...FragA
    50          }
    51          fragment FragA on Type {
    52            field(a: $a) {
    53              ...FragB
    54            }
    55          }
    56          fragment FragB on Type {
    57            field(b: $b) {
    58              ...FragC
    59            }
    60          }
    61          fragment FragC on Type {
    62            field(c: $c)
    63          }
    64          
    65  errors: []
    66- name: variable within single fragment defined in multiple operations
    67  rule: NoUndefinedVariables
    68  schema: 0
    69  query: |2-
    70          
    71          query Foo($a: String) {
    72            ...FragA
    73          }
    74          query Bar($a: String) {
    75            ...FragA
    76          }
    77          fragment FragA on Type {
    78            field(a: $a)
    79          }
    80          
    81  errors: []
    82- name: variable within fragments defined in operations
    83  rule: NoUndefinedVariables
    84  schema: 0
    85  query: |2-
    86          
    87          query Foo($a: String) {
    88            ...FragA
    89          }
    90          query Bar($b: String) {
    91            ...FragB
    92          }
    93          fragment FragA on Type {
    94            field(a: $a)
    95          }
    96          fragment FragB on Type {
    97            field(b: $b)
    98          }
    99          
   100  errors: []
   101- name: variable within recursive fragment defined
   102  rule: NoUndefinedVariables
   103  schema: 0
   104  query: |2-
   105          
   106          query Foo($a: String) {
   107            ...FragA
   108          }
   109          fragment FragA on Type {
   110            field(a: $a) {
   111              ...FragA
   112            }
   113          }
   114          
   115  errors: []
   116- name: variable not defined
   117  rule: NoUndefinedVariables
   118  schema: 0
   119  query: |2-
   120          
   121          query Foo($a: String, $b: String, $c: String) {
   122            field(a: $a, b: $b, c: $c, d: $d)
   123          }
   124          
   125  errors:
   126    - message: Variable "$d" is not defined by operation "Foo".
   127      locations:
   128        - {line: 3, column: 39}
   129        - {line: 2, column: 7}
   130- name: variable not defined by un-named query
   131  rule: NoUndefinedVariables
   132  schema: 0
   133  query: |2-
   134          
   135          {
   136            field(a: $a)
   137          }
   138          
   139  errors:
   140    - message: Variable "$a" is not defined.
   141      locations:
   142        - {line: 3, column: 18}
   143        - {line: 2, column: 7}
   144- name: multiple variables not defined
   145  rule: NoUndefinedVariables
   146  schema: 0
   147  query: |2-
   148          
   149          query Foo($b: String) {
   150            field(a: $a, b: $b, c: $c)
   151          }
   152          
   153  errors:
   154    - message: Variable "$a" is not defined by operation "Foo".
   155      locations:
   156        - {line: 3, column: 18}
   157        - {line: 2, column: 7}
   158    - message: Variable "$c" is not defined by operation "Foo".
   159      locations:
   160        - {line: 3, column: 32}
   161        - {line: 2, column: 7}
   162- name: variable in fragment not defined by un-named query
   163  rule: NoUndefinedVariables
   164  schema: 0
   165  query: |2-
   166          
   167          {
   168            ...FragA
   169          }
   170          fragment FragA on Type {
   171            field(a: $a)
   172          }
   173          
   174  errors:
   175    - message: Variable "$a" is not defined.
   176      locations:
   177        - {line: 6, column: 18}
   178        - {line: 2, column: 7}
   179- name: variable in fragment not defined by operation
   180  rule: NoUndefinedVariables
   181  schema: 0
   182  query: |2-
   183          
   184          query Foo($a: String, $b: String) {
   185            ...FragA
   186          }
   187          fragment FragA on Type {
   188            field(a: $a) {
   189              ...FragB
   190            }
   191          }
   192          fragment FragB on Type {
   193            field(b: $b) {
   194              ...FragC
   195            }
   196          }
   197          fragment FragC on Type {
   198            field(c: $c)
   199          }
   200          
   201  errors:
   202    - message: Variable "$c" is not defined by operation "Foo".
   203      locations:
   204        - {line: 16, column: 18}
   205        - {line: 2, column: 7}
   206- name: multiple variables in fragments not defined
   207  rule: NoUndefinedVariables
   208  schema: 0
   209  query: |2-
   210          
   211          query Foo($b: String) {
   212            ...FragA
   213          }
   214          fragment FragA on Type {
   215            field(a: $a) {
   216              ...FragB
   217            }
   218          }
   219          fragment FragB on Type {
   220            field(b: $b) {
   221              ...FragC
   222            }
   223          }
   224          fragment FragC on Type {
   225            field(c: $c)
   226          }
   227          
   228  errors:
   229    - message: Variable "$a" is not defined by operation "Foo".
   230      locations:
   231        - {line: 6, column: 18}
   232        - {line: 2, column: 7}
   233    - message: Variable "$c" is not defined by operation "Foo".
   234      locations:
   235        - {line: 16, column: 18}
   236        - {line: 2, column: 7}
   237- name: single variable in fragment not defined by multiple operations
   238  rule: NoUndefinedVariables
   239  schema: 0
   240  query: |2-
   241          
   242          query Foo($a: String) {
   243            ...FragAB
   244          }
   245          query Bar($a: String) {
   246            ...FragAB
   247          }
   248          fragment FragAB on Type {
   249            field(a: $a, b: $b)
   250          }
   251          
   252  errors:
   253    - message: Variable "$b" is not defined by operation "Foo".
   254      locations:
   255        - {line: 9, column: 25}
   256        - {line: 2, column: 7}
   257    - message: Variable "$b" is not defined by operation "Bar".
   258      locations:
   259        - {line: 9, column: 25}
   260        - {line: 5, column: 7}
   261- name: variables in fragment not defined by multiple operations
   262  rule: NoUndefinedVariables
   263  schema: 0
   264  query: |2-
   265          
   266          query Foo($b: String) {
   267            ...FragAB
   268          }
   269          query Bar($a: String) {
   270            ...FragAB
   271          }
   272          fragment FragAB on Type {
   273            field(a: $a, b: $b)
   274          }
   275          
   276  errors:
   277    - message: Variable "$a" is not defined by operation "Foo".
   278      locations:
   279        - {line: 9, column: 18}
   280        - {line: 2, column: 7}
   281    - message: Variable "$b" is not defined by operation "Bar".
   282      locations:
   283        - {line: 9, column: 25}
   284        - {line: 5, column: 7}
   285- name: variable in fragment used by other operation
   286  rule: NoUndefinedVariables
   287  schema: 0
   288  query: |2-
   289          
   290          query Foo($b: String) {
   291            ...FragA
   292          }
   293          query Bar($a: String) {
   294            ...FragB
   295          }
   296          fragment FragA on Type {
   297            field(a: $a)
   298          }
   299          fragment FragB on Type {
   300            field(b: $b)
   301          }
   302          
   303  errors:
   304    - message: Variable "$a" is not defined by operation "Foo".
   305      locations:
   306        - {line: 9, column: 18}
   307        - {line: 2, column: 7}
   308    - message: Variable "$b" is not defined by operation "Bar".
   309      locations:
   310        - {line: 12, column: 18}
   311        - {line: 5, column: 7}
   312- name: multiple undefined variables produce multiple errors
   313  rule: NoUndefinedVariables
   314  schema: 0
   315  query: |2-
   316          
   317          query Foo($b: String) {
   318            ...FragAB
   319          }
   320          query Bar($a: String) {
   321            ...FragAB
   322          }
   323          fragment FragAB on Type {
   324            field1(a: $a, b: $b)
   325            ...FragC
   326            field3(a: $a, b: $b)
   327          }
   328          fragment FragC on Type {
   329            field2(c: $c)
   330          }
   331          
   332  errors:
   333    - message: Variable "$a" is not defined by operation "Foo".
   334      locations:
   335        - {line: 9, column: 19}
   336        - {line: 2, column: 7}
   337    - message: Variable "$a" is not defined by operation "Foo".
   338      locations:
   339        - {line: 11, column: 19}
   340        - {line: 2, column: 7}
   341    - message: Variable "$c" is not defined by operation "Foo".
   342      locations:
   343        - {line: 14, column: 19}
   344        - {line: 2, column: 7}
   345    - message: Variable "$b" is not defined by operation "Bar".
   346      locations:
   347        - {line: 9, column: 26}
   348        - {line: 5, column: 7}
   349    - message: Variable "$b" is not defined by operation "Bar".
   350      locations:
   351        - {line: 11, column: 26}
   352        - {line: 5, column: 7}
   353    - message: Variable "$c" is not defined by operation "Bar".
   354      locations:
   355        - {line: 14, column: 19}
   356        - {line: 5, column: 7}

View as plain text