|
| 1 | +moduleInternal= { |
| 2 | +moduleKind= { |
| 3 | +typet=string; |
| 4 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalname:t="NAME"; |
| 5 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 6 | +externaldocument:t="DOCUMENT"; |
| 7 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 8 | +externaloperationDefinition:t="OPERATION_DEFINITION"; |
| 9 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 10 | +externalvariableDefinition:t="VARIABLE_DEFINITION"; |
| 11 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 12 | +externalvariable:t="VARIABLE"; |
| 13 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 14 | +externalselectionSet:t="SELECTION_SET"; |
| 15 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalfield:t="FIELD"; |
| 16 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 17 | +externalargument:t="ARGUMENT"; |
| 18 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 19 | +externalfragmentSpread:t="FRAGMENT_SPREAD"; |
| 20 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 21 | +externalinlineFragment:t="INLINE_FRAGMENT"; |
| 22 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 23 | +externalfragmentDefinition:t="FRAGMENT_DEFINITION"; |
| 24 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalint:t="INT"; |
| 25 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalfloat:t="FLOAT"; |
| 26 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalstring:t="STRING"; |
| 27 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalboolean:t="BOOLEAN"; |
| 28 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalnull:t="NULL"; |
| 29 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalenum:t="ENUM"; |
| 30 | + [@bs.module"graphql"] [@bs.scope"Kind"]externallist:t="LIST"; |
| 31 | + [@bs.module"graphql"] [@bs.scope"Kind"]externalobject_:t="OBJECT"; |
| 32 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 33 | +externalobjectField:t="OBJECT_FIELD"; |
| 34 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 35 | +externaldirective:t="DIRECTIVE"; |
| 36 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 37 | +externalnamedType:t="NAMED_TYPE"; |
| 38 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 39 | +externallistType:t="LIST_TYPE"; |
| 40 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 41 | +externalnonNullType:t="NON_NULL_TYPE"; |
| 42 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 43 | +externalschemaDefinition:t="SCHEMA_DEFINITION"; |
| 44 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 45 | +externaloperationTypeDefinition:t="OPERATION_TYPE_DEFINITION"; |
| 46 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 47 | +externalscalarTypeDefinition:t="SCALAR_TYPE_DEFINITION"; |
| 48 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 49 | +externalobjectTypeDefinition:t="OBJECT_TYPE_DEFINITION"; |
| 50 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 51 | +externalfieldDefinition:t="FIELD_DEFINITION"; |
| 52 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 53 | +externalinputValueDefinition:t="INPUT_VALUE_DEFINITION"; |
| 54 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 55 | +externalinterfaceTypeDefinition:t="INTERFACE_TYPE_DEFINITION"; |
| 56 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 57 | +externalunionTypeDefinition:t="UNION_TYPE_DEFINITION"; |
| 58 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 59 | +externalenumTypeDefinition:t="ENUM_TYPE_DEFINITION"; |
| 60 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 61 | +externalenumValueDefinition:t="ENUM_VALUE_DEFINITION"; |
| 62 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 63 | +externalinputObjectTypeDefinition:t="INPUT_OBJECT_TYPE_DEFINITION"; |
| 64 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 65 | +externalscalarTypeExtension:t="SCALAR_TYPE_EXTENSION"; |
| 66 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 67 | +externalobjectTypeExtension:t="OBJECT_TYPE_EXTENSION"; |
| 68 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 69 | +externalinterfaceTypeExtension:t="INTERFACE_TYPE_EXTENSION"; |
| 70 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 71 | +externalunionTypeExtension:t="UNION_TYPE_EXTENSION"; |
| 72 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 73 | +externalenumTypeExtension:t="ENUM_TYPE_EXTENSION"; |
| 74 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 75 | +externalinputObjectTypeExtension:t="INPUT_OBJECT_TYPE_EXTENSION"; |
| 76 | + [@bs.module"graphql"] [@bs.scope"Kind"] |
| 77 | +externaldirectiveDefinition:t="DIRECTIVE_DEFINITION"; |
| 78 | + }; |
| 79 | +typenode= {. "kind":Kind.t}; |
| 80 | +moduleSource= { |
| 81 | +typet; |
| 82 | + [@bs.module"graphql"] [@bs.new] |
| 83 | +externalmake: (string,string) =>t="Source"; |
| 84 | + }; |
| 85 | + [@bs.module"graphql"]externalparse:Source.t =>node=""; |
| 86 | +}; |
| 87 | + |
| 88 | +typesource= { |
| 89 | + body:string, |
| 90 | + name:string |
| 91 | +}; |
| 92 | + |
| 93 | +typeloc= { |
| 94 | + start:int, |
| 95 | + end_:int, |
| 96 | + source |
| 97 | +}; |
| 98 | + |
| 99 | +typedocument= { |
| 100 | + definitions:array(node), |
| 101 | + loc |
| 102 | +} |
| 103 | +andobjectTypeDefinition= { |
| 104 | + name:node, |
| 105 | + interfaces:array(node), |
| 106 | + directives:array(node), |
| 107 | + fields:array(node), |
| 108 | + loc |
| 109 | +} |
| 110 | +and fieldDefinition = { |
| 111 | +name: node, |
| 112 | + arguments: array(node), |
| 113 | + type_: node, |
| 114 | + directives: array(node), |
| 115 | + loc |
| 116 | +} |
| 117 | +and inputValueDefinition= { |
| 118 | + name: node, |
| 119 | + type_: node, |
| 120 | + defaultValue: option(node), |
| 121 | + directives: array(node), |
| 122 | + loc |
| 123 | +} |
| 124 | +and namedType= { |
| 125 | + name: node, |
| 126 | + loc |
| 127 | +} |
| 128 | +and nonNullType= { |
| 129 | + type_: node, |
| 130 | + loc |
| 131 | +} |
| 132 | +and name= { |
| 133 | + value: string, |
| 134 | + loc |
| 135 | +} |
| 136 | +and node= |
| 137 | + |Document(document) |
| 138 | + |ObjectTypeDefinition(objectTypeDefinition) |
| 139 | + |FieldDefinition(fieldDefinition) |
| 140 | + |InputValueDefinition(inputValueDefinition) |
| 141 | + |NamedType(namedType) |
| 142 | + |NonNullType(nonNullType) |
| 143 | + |Name(name) |
| 144 | + |Unknown(string); |
| 145 | + |
| 146 | +moduleDecoder= { |
| 147 | +letsource= json=> |
| 148 | +Json.Decode.{ |
| 149 | + body: json|> field("body", string), |
| 150 | + name: json|> field("name", string) |
| 151 | + }; |
| 152 | +letloc= json=> |
| 153 | +Json.Decode.{ |
| 154 | + start: json|> field("start", int), |
| 155 | + end_: json|> field("end", int), |
| 156 | + source: json|> field("source", source) |
| 157 | + }; |
| 158 | +externalnodeToJson:Internal.node =>Js.Json.t="%identity"; |
| 159 | +letrecdecoders=[ |
| 160 | + (Internal.Kind.document, document), |
| 161 | + (Internal.Kind.objectTypeDefinition, objectTypeDefinition), |
| 162 | + (Internal.Kind.fieldDefinition, fieldDefinition), |
| 163 | + (Internal.Kind.inputValueDefinition, inputValueDefinition), |
| 164 | + (Internal.Kind.namedType, namedType), |
| 165 | + (Internal.Kind.nonNullType, nonNullType), |
| 166 | + (Internal.Kind.name, name) |
| 167 | +] |
| 168 | +andnode= json=> { |
| 169 | +letkind= json|>Json.Decode.field("kind",Json.Decode.string); |
| 170 | +letdecoder= |
| 171 | +try (List.assoc(kind, decoders)) { |
| 172 | +|_=> unknown |
| 173 | + }; |
| 174 | + decoder(json); |
| 175 | + } |
| 176 | +anddocument= json=> |
| 177 | +Document( |
| 178 | +Json.Decode.{ |
| 179 | + definitions: json|> field("definitions", array(node)), |
| 180 | + loc: json|> field("loc", loc) |
| 181 | + } |
| 182 | + ) |
| 183 | +andobjectTypeDefinition= json=> |
| 184 | +ObjectTypeDefinition( |
| 185 | +Json.Decode.{ |
| 186 | + name: json|> field("name", node), |
| 187 | + interfaces: json|> field("interfaces", array(node)), |
| 188 | + directives: json|> field("directives", array(node)), |
| 189 | + fields: json|> field("fields", array(node)), |
| 190 | + loc: json|> field("loc", loc) |
| 191 | + } |
| 192 | + ) |
| 193 | +andfieldDefinition= json=> |
| 194 | +FieldDefinition( |
| 195 | +Json.Decode.{ |
| 196 | + name: json|> field("name", node), |
| 197 | + arguments: json|> field("arguments", array(node)), |
| 198 | + type_: json|> field("type", node), |
| 199 | + directives: json|> field("directives", array(node)), |
| 200 | + loc: json|> field("loc", loc) |
| 201 | + } |
| 202 | + ) |
| 203 | +andinputValueDefinition= json=> |
| 204 | +InputValueDefinition( |
| 205 | +Json.Decode.{ |
| 206 | + name: json|> field("name", node), |
| 207 | + type_: json|> field("type", node), |
| 208 | + defaultValue: json|> optional(field("defaultValue", node)), |
| 209 | + directives: json|> field("directives", array(node)), |
| 210 | + loc: json|> field("loc", loc) |
| 211 | + } |
| 212 | + ) |
| 213 | +andnamedType= json=> |
| 214 | +NamedType( |
| 215 | +Json.Decode.{ |
| 216 | + name: json|> field("name", node), |
| 217 | + loc: json|> field("loc", loc) |
| 218 | + } |
| 219 | + ) |
| 220 | +andnonNullType= json=> |
| 221 | +NonNullType( |
| 222 | +Json.Decode.{ |
| 223 | + type_: json|> field("type", node), |
| 224 | + loc: json|> field("loc", loc) |
| 225 | + } |
| 226 | + ) |
| 227 | +andname= json=> |
| 228 | +Name( |
| 229 | +Json.Decode.{ |
| 230 | + value: json|> field("value", string), |
| 231 | + loc: json|> field("loc", loc) |
| 232 | + } |
| 233 | + ) |
| 234 | +andunknown= json=> { |
| 235 | +letkind=Json.Decode.field("kind",Json.Decode.string, json); |
| 236 | +Unknown(kind); |
| 237 | + }; |
| 238 | +letdecode= graphqlNode=> { |
| 239 | +letjson= nodeToJson(graphqlNode); |
| 240 | + node(json); |
| 241 | + }; |
| 242 | +}; |
| 243 | + |
| 244 | +letparse= (fileName:string, source:string)=> { |
| 245 | +letsourceFile=Internal.Source.make(source, fileName); |
| 246 | +letparsedSource=Internal.parse(sourceFile); |
| 247 | +Decoder.decode(parsedSource); |
| 248 | +}; |