Skip to content

Instantly share code, notes, and snippets.

@thenamankumar
Created July 22, 2020 16:03
Show Gist options
  • Save thenamankumar/29f429203137ef0d4445e33b9f78a287 to your computer and use it in GitHub Desktop.
Save thenamankumar/29f429203137ef0d4445e33b9f78a287 to your computer and use it in GitHub Desktop.
{
"SourceCharacter": { "ofPattern": "[\u0009\u000A\u000D\u0020-\uFFFF]" },
"UnicodeBOM": { "ofValue": "\uFEFF" },
"WhiteSpace": { "oneOf": ["\t", " "] },
"LineTerminator": { "oneOfType": [{ "ofValue": "\n" }, { "ofValue": "\r" }, { "ofPattern": "\r\n" }] },
"Comment": [{ "ofValue": "#" }, "CommentChar"],
"CommentChar": { "ofType": "SourceCharacter", "butNot": "LineTerminator" },
"Comma": { "punctuator": "," },
"Token": { "oneOfType": ["Punctuator", "Name", "IntValue", "FloatValue", "StringValue"] },
"Ignored": { "oneOfType": ["UnicodeBOM", "WhiteSpace", "LineTerminator", "Comment", "Comma"] },
"Punctuator": { "oneOf": ["!", "$", "(", ")", "...", ":", "=", "@", "[", "]", "{", "|", "}"] },
"Name": { "ofPattern": "[_A-Za-z][_0-9A-Za-z]*" },
"Document": { "listOfType": "Definition" },
"Definition": { "oneOfType": ["ExecutableDefinition", "TypeSystemDefinition", "TypeSystemExtension"] },
"ExecutableDefinition": { "oneOfType": ["OperationDefinition", "FragmentDefinition"] },
"OperationDefinition": {
"oneOfType": [
[
"OperationType",
{ "ofType": "Name", "optional": true },
{ "ofType": "VariableDefinitions", "optional": true },
{ "ofType": "Directives", "optional": true },
"SelectionSet"
],
"SelectionSet"
]
},
"OperationType": { "oneOfType": [{ "keyword": "query" }, { "keyword": "mutation" }, { "keyword": "subscription" }] },
"SelectionSet": [{ "punctuator": "{" }, { "listOfType": "Selection" }, { "punctuator": "}" }],
"Selection": { "oneOfType": ["Field", "FragmentSpread", "InlineFragment"] },
"Field": [
{ "ofType": "Alias", "optional": true },
"Name",
{ "ofType": "Arguments", "optional": true },
{ "ofType": "Directives", "optional": true },
{ "ofType": "SelectionSet", "optional": true }
],
"Arguments": [{ "punctuator": "(" }, { "listOfType": "Argument" }, { "punctuator": ")" }],
"Argument": ["Name", { "punctuator": ":" }, "Value"],
"Alias": ["Name", { "punctuator": ":" }],
"FragmentSpread": [{ "punctuator": "..." }, "FragmentName", { "ofType": "Directives", "optional": true }],
"FragmentDefinition": [
{ "keyword": "fragment" },
"FragmentName",
"TypeCondition",
{ "ofType": "Directives", "optional": true },
"SelectionSet"
],
"FragmentName": { "ofType": "Name", "butNot": { "keyword": "on" } },
"TypeCondition": [{ "keyword": "on" }, "NamedType"],
"InlineFragment": [
{ "punctuator": "..." },
{ "ofType": "TypeCondition", "optional": true },
{ "ofType": "Directives", "optional": true },
"SelectionSet"
],
"Value": {
"oneOfType": [
"Variable",
"IntValue",
"FloatValue",
"StringValue",
"BooleanValue",
"NullValue",
"EnumValue",
"ListValue",
"ObjectValue"
]
},
"IntValue": "IntegerPart",
"IntegerPart": {
"oneOfType": [
[{ "ofType": "NegativeSign", "optional": true }, { "ofValue": "0" }],
[{ "ofType": "NegativeSign", "optional": true }, "NonZeroDigit", { "listOfType": "Digit", "optional": true }]
]
},
"NegativeSign": { "ofValue": "-" },
"Digit": { "oneOf": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] },
"NonZeroDigit": { "ofType": "Digit", "butNot": { "ofValue": "0" } },
"FloatValue": {
"oneOfType": [
["IntegerPart", "FractionalPart"],
["IntegerPart", "ExponentPart"],
["IntegerPart", "FractionalPart", "ExponentPart"]
]
},
"FractionalPart": [{ "ofValue": "." }, { "listOfType": "Digit" }],
"ExponentPart": ["ExponentIndicator", { "ofType": "Sign", "optional": true }, { "listOfType": "Digit" }],
"ExponentIndicator": { "oneOf": ["e", "E"] },
"Sign": { "oneOf": ["+", "-"] },
"BooleanValue": { "oneOf": ["true", "false"] },
"StringValue": {
"oneOfType": [
[{ "ofValue": "\"" }, { "listOfType": "StringCharacter", "optional": true }, { "ofValue": "\"" }],
[{ "ofValue": "\"\"\"" }, { "listOfType": "BlockStringCharacter", "optional": true }, { "ofValue": "\"\"\"" }]
]
},
"StringCharacter": {
"ofType": "SourceCharacter",
"butNot": [{ "ofValue": "\"" }, { "ofValue": "\\" }, "LineTerminator", "EscapedUnicode", "EscapedCharacter"]
},
"EscapedUnicode": { "ofPattern": "[\u0000-\uFFFF]" },
"EscapedCharacter": { "ofPattern": "(\"|\\|\b|\f|\n|\r|\t)" },
"BlockStringCharacter": {
"ofType": "SourceCharacter",
"butNot": [
{ "ofValue": "\"\"\"" },
{ "ofValue": "\\\"\"\"" },
"LineTerminator",
"EscapedUnicode",
"EscapedCharacter"
]
},
"NullValue": { "keword": "null" },
"EnumValue": { "ofType": "Name", "butNot": ["BooleanValue", "NullValue"] },
"ListValue": [{ "punctuator": "[" }, { "listOfType": "Value", "optional": true }, { "punctuator": "]" }],
"ObjectValue": [{ "punctuator": "{" }, { "listOfType": "ObjectField", "optional": true }, { "punctuator": "}" }],
"ObjectField": ["Name", { "punctuator": ":" }, "Value"],
"Variable": [{ "punctuator": "$" }, "Name"],
"VariableDefinitions": [{ "punctuator": "(" }, { "listOfType": "VariableDefinition" }, { "punctuator": ")" }],
"VariableDefinition": ["Variable", { "punctuator": ":" }, "Type", { "ofType": "DefaultValue", "optional": true }],
"DefaultValue": [{ "punctuator": "=" }, "Value"],
"Type": { "oneOfType": ["NamedType", "ListType", "NonNullType"] },
"NamedType": "Name",
"ListType": [{ "punctuator": "[" }, { "listOfType": "Type" }, { "punctuator": "]" }],
"NonNullType": {
"oneOfType": [
["NamedType", { "punctuator": "!" }],
["ListType", { "punctuator": "!" }]
]
},
"Directives": { "listOfType": "Directive" },
"Directive": [{ "punctuator": "@" }, "Name", { "ofType": "Arguments", "optional": true }],
"TypeSystemDefinition": { "oneOfType": ["SchemaDefinition", "TypeDefinition", "DirectiveDefinition"] },
"TypeSystemExtension": { "oneOfType": ["SchemaExtension", "TypeExtension"] },
"SchemaDefinition": [
{ "keyword": "schema" },
{ "ofType": "Directives", "optional": true },
{ "punctuator": "{" },
{ "listOfType": "RootOperationTypeDefinition" },
{ "punctuator": "}" }
],
"RootOperationTypeDefinition": ["OperationType", "NamedType"],
"SchemaExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "schema" },
{ "ofType": "Directives", "optional": true },
{ "punctuator": "{" },
{ "listOfType": "OperationTypeDefinition" },
{ "punctuator": "}" }
],
[{ "keyword": "extend" }, { "keyword": "schema" }, "Directives"]
]
},
"Description": "StringValue",
"TypeDefinition": {
"oneOfType": [
"ScalarTypeExtension",
"ObjectTypeExtension",
"InterfaceTypeExtension",
"UnionTypeExtension",
"EnumTypeExtension",
"InputObjectTypeExtension"
]
},
"ScalarTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "scalar" },
"Name",
{ "ofType": "Directives", "optional": true }
],
"ScalarTypeExtension": [{ "keyword": "extend" }, { "keyword": "scalar" }, "Name", "Directives"],
"ObjectTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "type" },
"Name",
{ "ofType": "ImplementsInterfaces", "optional": true },
{ "ofType": "Directives", "optional": true },
{ "ofType": "FieldsDefinition", "optional": true }
],
"ImplementsInterfaces": {
"oneOfType": [
[{ "keyword": "implements" }, { "ofValue": "&", "optional": true }, "NamedType"],
["ImplementsInterfaces", { "ofValue": "&" }, "NamedType"]
]
},
"FieldsDefinition": [{ "punctuator": "{" }, { "listOfType": "FieldDefinition" }, { "punctuator": "}" }],
"FieldDefinition": [
{ "ofType": "Description", "optional": true },
"Name",
{ "ofType": "ArgumentsDefinition", "optional": true },
{ "punctuator": ":" },
"Type",
{ "ofType": "Directives", "optional": true }
],
"ArgumentsDefinition": [{ "punctuator": "(" }, { "listOfType": "InputValueDefinition" }, { "ofValue": ")" }],
"InputValueDefinition": [
{ "ofType": "Description", "optional": true },
"Name",
{ "punctuator": ":" },
"Type",
{ "ofType": "DefaultValue", "optional": true },
{ "ofType": "Directives", "optional": true }
],
"ObjectTypeExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "type" },
"Name",
{ "ofType": "ImplementsInterfaces", "optional": true },
{ "ofType": "Directives", "optional": true },
"FieldsDefinition"
],
[
{ "keyword": "extend" },
{ "keyword": "type" },
"Name",
{ "ofType": "ImplementsInterfaces", "optional": true },
"Directives"
],
[{ "keyword": "extend" }, { "keyword": "type" }, "Name", "ImplementsInterfaces"]
]
},
"InterfaceTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "interface" },
"Name",
{ "ofType": "Directives", "optional": true },
{ "ofType": "FieldsDefinition", "optional": true }
],
"InterfaceTypeExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "interface" },
"Name",
{ "ofType": "Directives", "optional": true },
"FieldsDefinition"
],
[{ "keyword": "extend" }, { "keyword": "interface" }, "Name", "Directives"]
]
},
"UnionTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "union" },
"Name",
{ "ofType": "Directives", "optional": true },
{ "ofType": "UnionMemberTypes", "optional": true }
],
"UnionMemberTypes": {
"oneOfType": [
[{ "punctuator": "=" }, { "punctuator": "|", "optional": true }, "NamedType"],
["UnionMemberTypes", { "punctuator": "|" }, "NamedType"]
]
},
"UnionTypeExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "union" },
"Name",
{ "ofType": "Directives", "optional": true },
"UnionMemberTypes"
],
[{ "keyword": "extend" }, { "keyword": "union" }, "Name", "Directives"]
]
},
"EnumTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "enum" },
"Name",
{ "ofType": "Directives", "optional": true },
{ "ofType": "EnumValuesDefinition", "optional": true }
],
"EnumValuesDefinition": [{ "punctuator": "{" }, { "listOfType": "EnumValueDefinition" }, { "ofValue": "}" }],
"EnumValueDefinition": [
{ "ofType": "Description", "optional": true },
"EnumValue",
{ "ofType": "Directives", "optional": true }
],
"EnumTypeExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "enum" },
"Name",
{ "ofType": "Directives", "optional": true },
"EnumValuesDefinition"
],
[{ "keyword": "extend" }, { "keyword": "enum" }, "Name", "Directives"]
]
},
"InputObjectTypeDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "input" },
"Name",
{ "ofType": "Directives", "optional": true },
{ "ofType": "InputFieldsDefinition", "optional": true }
],
"InputFieldsDefinition": [{ "punctuator": "{" }, { "listOfType": "InputValueDefinition" }, { "ofValue": "}" }],
"InputObjectTypeExtension": {
"oneOfType": [
[
{ "keyword": "extend" },
{ "keyword": "input" },
"Name",
{ "ofType": "Directives", "optional": true },
"InputFieldsDefinition"
],
[{ "keyword": "extend" }, { "keyword": "input" }, "Name", "Directives"]
]
},
"DirectiveDefinition": [
{ "ofType": "Description", "optional": true },
{ "keyword": "directive" },
{ "punctuator": "@" },
"Name",
{ "ofType": "ArgumentsDefinition", "optional": true },
{ "keyword": "on" },
"DirectiveLocations"
],
"DirectiveLocations": {
"oneOfType": [
[{ "punctuator": "|", "optional": true }, "DirectiveLocation"],
["DirectiveLocations", { "punctuator": "|" }, "DirectiveLocation"]
]
},
"DirectiveLocation": { "oneOfType": ["ExecutableDirectiveLocation", "TypeSystemDirectiveLocation"] },
"ExecutableDirectiveLocation": {
"oneOf": ["QUERY", "MUTATION", "SUBSCRIPTION", "FIELD", "FRAGMENT_DEFINITION", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"]
},
"TypeSystemDirectiveLocation": {
"oneOf": [
"SCHEMA",
"SCALAR",
"OBJECT",
"FIELD_DEFINITION",
"ARGUMENT_DEFINITION",
"INTERFACE",
"UNION",
"ENUM",
"ENUM_VALUE",
"INPUT_OBJECT",
"INPUT_FIELD_DEFINITION"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment