...

Text file src/github.com/vektah/gqlparser/parser/schema_test.yml

Documentation: github.com/vektah/gqlparser/parser

     1object types:
     2  - name: simple
     3    input: |
     4      type Hello {
     5        world: String
     6      }
     7    ast: |
     8      <SchemaDocument>
     9        Definitions: [Definition]
    10        - <Definition>
    11            Kind: DefinitionKind("OBJECT")
    12            Name: "Hello"
    13            Fields: [FieldDefinition]
    14            - <FieldDefinition>
    15                Name: "world"
    16                Type: String
    17
    18  - name: with description
    19    input: |
    20      "Description"
    21      type Hello {
    22        world: String
    23      }
    24    ast: |
    25      <SchemaDocument>
    26        Definitions: [Definition]
    27        - <Definition>
    28            Kind: DefinitionKind("OBJECT")
    29            Description: "Description"
    30            Name: "Hello"
    31            Fields: [FieldDefinition]
    32            - <FieldDefinition>
    33                Name: "world"
    34                Type: String
    35
    36  - name: with block description
    37    input: |
    38      """
    39      Description
    40      """
    41      # Even with comments between them
    42      type Hello {
    43        world: String
    44      }
    45    ast: |
    46      <SchemaDocument>
    47        Definitions: [Definition]
    48        - <Definition>
    49            Kind: DefinitionKind("OBJECT")
    50            Description: "Description"
    51            Name: "Hello"
    52            Fields: [FieldDefinition]
    53            - <FieldDefinition>
    54                Name: "world"
    55                Type: String
    56  - name: with field arg
    57    input: |
    58      type Hello {
    59        world(flag: Boolean): String
    60      }
    61    ast: |
    62      <SchemaDocument>
    63        Definitions: [Definition]
    64        - <Definition>
    65            Kind: DefinitionKind("OBJECT")
    66            Name: "Hello"
    67            Fields: [FieldDefinition]
    68            - <FieldDefinition>
    69                Name: "world"
    70                Arguments: [ArgumentDefinition]
    71                - <ArgumentDefinition>
    72                    Name: "flag"
    73                    Type: Boolean
    74                Type: String
    75
    76  - name: with field arg and default value
    77    input: |
    78      type Hello {
    79        world(flag: Boolean = true): String
    80      }
    81    ast: |
    82      <SchemaDocument>
    83        Definitions: [Definition]
    84        - <Definition>
    85            Kind: DefinitionKind("OBJECT")
    86            Name: "Hello"
    87            Fields: [FieldDefinition]
    88            - <FieldDefinition>
    89                Name: "world"
    90                Arguments: [ArgumentDefinition]
    91                - <ArgumentDefinition>
    92                    Name: "flag"
    93                    DefaultValue: true
    94                    Type: Boolean
    95                Type: String
    96
    97  - name: with field list arg
    98    input: |
    99      type Hello {
   100        world(things: [String]): String
   101      }
   102    ast: |
   103      <SchemaDocument>
   104        Definitions: [Definition]
   105        - <Definition>
   106            Kind: DefinitionKind("OBJECT")
   107            Name: "Hello"
   108            Fields: [FieldDefinition]
   109            - <FieldDefinition>
   110                Name: "world"
   111                Arguments: [ArgumentDefinition]
   112                - <ArgumentDefinition>
   113                    Name: "things"
   114                    Type: [String]
   115                Type: String
   116
   117  - name: with two args
   118    input: |
   119      type Hello {
   120        world(argOne: Boolean, argTwo: Int): String
   121      }
   122    ast: |
   123      <SchemaDocument>
   124        Definitions: [Definition]
   125        - <Definition>
   126            Kind: DefinitionKind("OBJECT")
   127            Name: "Hello"
   128            Fields: [FieldDefinition]
   129            - <FieldDefinition>
   130                Name: "world"
   131                Arguments: [ArgumentDefinition]
   132                - <ArgumentDefinition>
   133                    Name: "argOne"
   134                    Type: Boolean
   135                - <ArgumentDefinition>
   136                    Name: "argTwo"
   137                    Type: Int
   138                Type: String
   139  - name: must define one or more fields
   140    input: |
   141      type Hello {}
   142    error:
   143      message: "expected at least one definition, found }"
   144      locations: [{ line: 1, column: 13 }]
   145
   146type extensions:
   147  - name: Object extension
   148    input: |
   149      extend type Hello {
   150        world: String
   151      }
   152    ast: |
   153      <SchemaDocument>
   154        Extensions: [Definition]
   155        - <Definition>
   156            Kind: DefinitionKind("OBJECT")
   157            Name: "Hello"
   158            Fields: [FieldDefinition]
   159            - <FieldDefinition>
   160                Name: "world"
   161                Type: String
   162
   163  - name: without any fields
   164    input: "extend type Hello implements Greeting"
   165    ast: |
   166      <SchemaDocument>
   167        Extensions: [Definition]
   168        - <Definition>
   169            Kind: DefinitionKind("OBJECT")
   170            Name: "Hello"
   171            Interfaces: [string]
   172            - "Greeting"
   173
   174  - name: without fields twice
   175    input: |
   176      extend type Hello implements Greeting
   177      extend type Hello implements SecondGreeting
   178    ast: |
   179      <SchemaDocument>
   180        Extensions: [Definition]
   181        - <Definition>
   182            Kind: DefinitionKind("OBJECT")
   183            Name: "Hello"
   184            Interfaces: [string]
   185            - "Greeting"
   186        - <Definition>
   187            Kind: DefinitionKind("OBJECT")
   188            Name: "Hello"
   189            Interfaces: [string]
   190            - "SecondGreeting"
   191
   192  - name: without anything errors
   193    input: "extend type Hello"
   194    error:
   195      message: "Unexpected <EOF>"
   196      locations: [{ line: 1, column: 18 }]
   197
   198  - name: can have descriptions # hmm, this might not be spec compliant...
   199    input: |
   200      "Description"
   201      extend type Hello {
   202        world: String
   203      }
   204    error:
   205      message: 'Unexpected String "Description"'
   206      locations: [{ line: 1, column: 2 }]
   207
   208  - name: can not have descriptions on types
   209    input: |
   210      extend "Description" type Hello {
   211        world: String
   212      }
   213    error:
   214      message: Unexpected String "Description"
   215      locations: [{ line: 1, column: 9 }]
   216
   217schema definition:
   218  - name: simple
   219    input: |
   220      schema {
   221        query: Query
   222      }
   223    ast: |
   224      <SchemaDocument>
   225        Schema: [SchemaDefinition]
   226        - <SchemaDefinition>
   227            OperationTypes: [OperationTypeDefinition]
   228            - <OperationTypeDefinition>
   229                Operation: Operation("query")
   230                Type: "Query"
   231
   232schema extensions:
   233  - name: simple
   234    input: |
   235       extend schema {
   236         mutation: Mutation
   237       }
   238    ast: |
   239      <SchemaDocument>
   240        SchemaExtension: [SchemaDefinition]
   241        - <SchemaDefinition>
   242            OperationTypes: [OperationTypeDefinition]
   243            - <OperationTypeDefinition>
   244                Operation: Operation("mutation")
   245                Type: "Mutation"
   246
   247  - name: directive only
   248    input: "extend schema @directive"
   249    ast: |
   250      <SchemaDocument>
   251        SchemaExtension: [SchemaDefinition]
   252        - <SchemaDefinition>
   253            Directives: [Directive]
   254            - <Directive>
   255                Name: "directive"
   256
   257  - name: without anything errors
   258    input: "extend schema"
   259    error:
   260      message: "Unexpected <EOF>"
   261      locations: [{ line: 1, column: 14}]
   262
   263type extensions:
   264  - name: all can have directives
   265    input: |
   266      extend scalar Foo @deprecated
   267      extend type Foo @deprecated
   268      extend interface Foo @deprecated
   269      extend union Foo @deprecated
   270      extend enum Foo @deprecated
   271      extend input Foo @deprecated
   272    ast: |
   273      <SchemaDocument>
   274        Extensions: [Definition]
   275        - <Definition>
   276            Kind: DefinitionKind("SCALAR")
   277            Name: "Foo"
   278            Directives: [Directive]
   279            - <Directive>
   280                Name: "deprecated"
   281        - <Definition>
   282            Kind: DefinitionKind("OBJECT")
   283            Name: "Foo"
   284            Directives: [Directive]
   285            - <Directive>
   286                Name: "deprecated"
   287        - <Definition>
   288            Kind: DefinitionKind("INTERFACE")
   289            Name: "Foo"
   290            Directives: [Directive]
   291            - <Directive>
   292                Name: "deprecated"
   293        - <Definition>
   294            Kind: DefinitionKind("UNION")
   295            Name: "Foo"
   296            Directives: [Directive]
   297            - <Directive>
   298                Name: "deprecated"
   299        - <Definition>
   300            Kind: DefinitionKind("ENUM")
   301            Name: "Foo"
   302            Directives: [Directive]
   303            - <Directive>
   304                Name: "deprecated"
   305        - <Definition>
   306            Kind: DefinitionKind("INPUT_OBJECT")
   307            Name: "Foo"
   308            Directives: [Directive]
   309            - <Directive>
   310                Name: "deprecated"
   311
   312
   313inheritance:
   314  - name: single
   315    input: "type Hello implements World { field: String }"
   316    ast: |
   317      <SchemaDocument>
   318        Definitions: [Definition]
   319        - <Definition>
   320            Kind: DefinitionKind("OBJECT")
   321            Name: "Hello"
   322            Interfaces: [string]
   323            - "World"
   324            Fields: [FieldDefinition]
   325            - <FieldDefinition>
   326                Name: "field"
   327                Type: String
   328
   329  - name: multi
   330    input: "type Hello implements Wo & rld { field: String }"
   331    ast: |
   332      <SchemaDocument>
   333        Definitions: [Definition]
   334        - <Definition>
   335            Kind: DefinitionKind("OBJECT")
   336            Name: "Hello"
   337            Interfaces: [string]
   338            - "Wo"
   339            - "rld"
   340            Fields: [FieldDefinition]
   341            - <FieldDefinition>
   342                Name: "field"
   343                Type: String
   344
   345  - name: multi with leading amp
   346    input: "type Hello implements & Wo & rld { field: String }"
   347    ast: |
   348      <SchemaDocument>
   349        Definitions: [Definition]
   350        - <Definition>
   351            Kind: DefinitionKind("OBJECT")
   352            Name: "Hello"
   353            Interfaces: [string]
   354            - "Wo"
   355            - "rld"
   356            Fields: [FieldDefinition]
   357            - <FieldDefinition>
   358                Name: "field"
   359                Type: String
   360
   361enums:
   362  - name: single value
   363    input: "enum Hello { WORLD }"
   364    ast: |
   365      <SchemaDocument>
   366        Definitions: [Definition]
   367        - <Definition>
   368            Kind: DefinitionKind("ENUM")
   369            Name: "Hello"
   370            EnumValues: [EnumValueDefinition]
   371            - <EnumValueDefinition>
   372                Name: "WORLD"
   373
   374  - name: double value
   375    input: "enum Hello { WO, RLD }"
   376    ast: |
   377      <SchemaDocument>
   378        Definitions: [Definition]
   379        - <Definition>
   380            Kind: DefinitionKind("ENUM")
   381            Name: "Hello"
   382            EnumValues: [EnumValueDefinition]
   383            - <EnumValueDefinition>
   384                Name: "WO"
   385            - <EnumValueDefinition>
   386                Name: "RLD"
   387  - name: must define one or more unique enum values
   388    input: |
   389      enum Hello {}
   390    error:
   391      message: "expected at least one definition, found }"
   392      locations: [{ line: 1, column: 13 }]
   393
   394interface:
   395  - name: simple
   396    input: |
   397      interface Hello {
   398        world: String
   399      }
   400    ast: |
   401      <SchemaDocument>
   402        Definitions: [Definition]
   403        - <Definition>
   404            Kind: DefinitionKind("INTERFACE")
   405            Name: "Hello"
   406            Fields: [FieldDefinition]
   407            - <FieldDefinition>
   408                Name: "world"
   409                Type: String
   410  - name: must define one or more fields
   411    input: |
   412      interface Hello {}
   413    error:
   414      message: "expected at least one definition, found }"
   415      locations: [{ line: 1, column: 18 }]
   416
   417unions:
   418  - name: simple
   419    input: "union Hello = World"
   420    ast: |
   421      <SchemaDocument>
   422        Definitions: [Definition]
   423        - <Definition>
   424            Kind: DefinitionKind("UNION")
   425            Name: "Hello"
   426            Types: [string]
   427            - "World"
   428
   429  - name: with two types
   430    input: "union Hello = Wo | Rld"
   431    ast: |
   432      <SchemaDocument>
   433        Definitions: [Definition]
   434        - <Definition>
   435            Kind: DefinitionKind("UNION")
   436            Name: "Hello"
   437            Types: [string]
   438            - "Wo"
   439            - "Rld"
   440
   441  - name: with leading pipe
   442    input: "union Hello = | Wo | Rld"
   443    ast: |
   444      <SchemaDocument>
   445        Definitions: [Definition]
   446        - <Definition>
   447            Kind: DefinitionKind("UNION")
   448            Name: "Hello"
   449            Types: [string]
   450            - "Wo"
   451            - "Rld"
   452
   453  - name: cant be empty
   454    input: "union Hello = || Wo | Rld"
   455    error:
   456      message: "Expected Name, found |"
   457      locations: [{ line: 1, column: 16 }]
   458
   459  - name: cant double pipe
   460    input: "union Hello = Wo || Rld"
   461    error:
   462      message: "Expected Name, found |"
   463      locations: [{ line: 1, column: 19 }]
   464
   465  - name: cant have trailing pipe
   466    input: "union Hello = | Wo | Rld |"
   467    error:
   468      message: "Expected Name, found <EOF>"
   469      locations: [{ line: 1, column: 27 }]
   470
   471scalar:
   472  - name: simple
   473    input: "scalar Hello"
   474    ast: |
   475      <SchemaDocument>
   476        Definitions: [Definition]
   477        - <Definition>
   478            Kind: DefinitionKind("SCALAR")
   479            Name: "Hello"
   480
   481input object:
   482  - name: simple
   483    input: |
   484      input Hello {
   485        world: String
   486      }
   487    ast: |
   488      <SchemaDocument>
   489        Definitions: [Definition]
   490        - <Definition>
   491            Kind: DefinitionKind("INPUT_OBJECT")
   492            Name: "Hello"
   493            Fields: [FieldDefinition]
   494            - <FieldDefinition>
   495                Name: "world"
   496                Type: String
   497
   498  - name: can not have args
   499    input: |
   500      input Hello {
   501        world(foo: Int): String
   502      }
   503    error:
   504      message: "Expected :, found ("
   505      locations: [{ line: 2, column: 8 }]
   506  - name: must define one or more input fields
   507    input: |
   508      input Hello {}
   509    error:
   510      message: "expected at least one definition, found }"
   511      locations: [{ line: 1, column: 14 }]
   512
   513directives:
   514  - name: simple
   515    input: directive @foo on FIELD
   516    ast: |
   517      <SchemaDocument>
   518        Directives: [DirectiveDefinition]
   519        - <DirectiveDefinition>
   520            Name: "foo"
   521            Locations: [DirectiveLocation]
   522            - DirectiveLocation("FIELD")
   523
   524  - name: invalid location
   525    input: "directive @foo on FIELD | INCORRECT_LOCATION"
   526    error:
   527      message: 'Unexpected Name "INCORRECT_LOCATION"'
   528      locations: [{ line: 1, column: 27 }]
   529
   530fuzzer:
   531  - name: 1
   532    input: "type o{d(g:["
   533    error:
   534      message: 'Expected Name, found <EOF>'
   535      locations: [{ line: 1, column: 13 }]
   536  - name: 2
   537    input: "\"\"\"\r"
   538    error:
   539      message: 'Unexpected <Invalid>'
   540      locations: [{ line: 1, column: 5 }]

View as plain text