Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: automatic introspection.ts for gql.tada (#165)

* automatic introspection.ts

* update readme

authored by

Jovi De Croock and committed by
GitHub
1d0302dc 2b4f99dd

+1413 -185
+5
.changeset/shiny-needles-arrive.md
··· 1 + --- 2 + '@0no-co/graphqlsp': minor 3 + --- 4 + 5 + Add option named `tadaOutputLocation` to automatically write the `introspection.ts` file
+3 -24
README.md
··· 59 59 you can opt into the object notation i.e. `{ "schema": { "url": "x", "headers": { "Authorization": "y" } }}` 60 60 61 61 **Optional** 62 - 63 62 - `template` add an additional template to the defaults `gql` and `graphql` 64 63 - `templateIsCallExpression` this tells our client that you are using `graphql('doc')` (default: true) 65 64 when using `false` it will look for tagged template literals 66 65 - `shouldCheckForColocatedFragments` when turned on, this will scan your imports to find 67 66 unused fragments and provide a message notifying you about them (only works with call-expressions, default: true) 68 67 - `trackFieldUsage` this only works with the client-preset, when turned on it will warn you about 69 - unused fields within the same file. (only works with call-expressions, default: true) 70 - 71 - ### GraphQL Code Generator client-preset 72 - 73 - For folks using the `client-preset` you can ues the following config 74 - 75 - ```json 76 - { 77 - "compilerOptions": { 78 - "plugins": [ 79 - { 80 - "name": "@0no-co/graphqlsp", 81 - "schema": "./schema.graphql", 82 - "disableTypegen": true, 83 - "templateIsCallExpression": true, 84 - "shouldCheckForColocatedFragments": true, 85 - "trackFieldUsage": true, 86 - "template": "graphql" 87 - } 88 - ] 89 - } 90 - } 91 - ``` 68 + unused fields within the same file. (only works with call-expressions, default: true) 69 + - `tadaOutputLocation` when using `gql.tada` this can be convenient as it automatically generates 70 + an `introspection.ts` file for you, just give it the directory to output to and you're done 92 71 93 72 ## Tracking unused fields 94 73
+1350 -138
packages/example-tada/introspection.ts
··· 7 7 subscriptionType: null, 8 8 types: [ 9 9 { 10 + kind: 'ENUM', 11 + name: 'PokemonType', 12 + description: 13 + 'Elemental property associated with either a Pokémon or one of their moves.', 14 + fields: null, 15 + inputFields: null, 16 + interfaces: null, 17 + enumValues: [ 18 + { 19 + name: 'Grass', 20 + description: null, 21 + isDeprecated: false, 22 + deprecationReason: null, 23 + }, 24 + { 25 + name: 'Poison', 26 + description: null, 27 + isDeprecated: false, 28 + deprecationReason: null, 29 + }, 30 + { 31 + name: 'Fire', 32 + description: null, 33 + isDeprecated: false, 34 + deprecationReason: null, 35 + }, 36 + { 37 + name: 'Flying', 38 + description: null, 39 + isDeprecated: false, 40 + deprecationReason: null, 41 + }, 42 + { 43 + name: 'Water', 44 + description: null, 45 + isDeprecated: false, 46 + deprecationReason: null, 47 + }, 48 + { 49 + name: 'Bug', 50 + description: null, 51 + isDeprecated: false, 52 + deprecationReason: null, 53 + }, 54 + { 55 + name: 'Normal', 56 + description: null, 57 + isDeprecated: false, 58 + deprecationReason: null, 59 + }, 60 + { 61 + name: 'Electric', 62 + description: null, 63 + isDeprecated: false, 64 + deprecationReason: null, 65 + }, 66 + { 67 + name: 'Ground', 68 + description: null, 69 + isDeprecated: false, 70 + deprecationReason: null, 71 + }, 72 + { 73 + name: 'Fairy', 74 + description: null, 75 + isDeprecated: false, 76 + deprecationReason: null, 77 + }, 78 + { 79 + name: 'Fighting', 80 + description: null, 81 + isDeprecated: false, 82 + deprecationReason: null, 83 + }, 84 + { 85 + name: 'Psychic', 86 + description: null, 87 + isDeprecated: false, 88 + deprecationReason: null, 89 + }, 90 + { 91 + name: 'Rock', 92 + description: null, 93 + isDeprecated: false, 94 + deprecationReason: null, 95 + }, 96 + { 97 + name: 'Steel', 98 + description: null, 99 + isDeprecated: false, 100 + deprecationReason: null, 101 + }, 102 + { 103 + name: 'Ice', 104 + description: null, 105 + isDeprecated: false, 106 + deprecationReason: null, 107 + }, 108 + { 109 + name: 'Ghost', 110 + description: null, 111 + isDeprecated: false, 112 + deprecationReason: null, 113 + }, 114 + { 115 + name: 'Dragon', 116 + description: null, 117 + isDeprecated: false, 118 + deprecationReason: null, 119 + }, 120 + { 121 + name: 'Dark', 122 + description: null, 123 + isDeprecated: false, 124 + deprecationReason: null, 125 + }, 126 + ], 127 + possibleTypes: null, 128 + }, 129 + { 10 130 kind: 'OBJECT', 11 131 name: 'Attack', 132 + description: 133 + 'Move a Pokémon can perform with the associated damage and type.', 12 134 fields: [ 13 135 { 14 - name: 'damage', 15 - type: { 16 - kind: 'SCALAR', 17 - name: 'Int', 18 - ofType: null, 19 - }, 136 + name: 'name', 137 + description: null, 20 138 args: [], 21 - }, 22 - { 23 - name: 'name', 24 139 type: { 25 140 kind: 'SCALAR', 26 141 name: 'String', 27 142 ofType: null, 28 143 }, 29 - args: [], 144 + isDeprecated: false, 145 + deprecationReason: null, 30 146 }, 31 147 { 32 148 name: 'type', 149 + description: null, 150 + args: [], 33 151 type: { 34 152 kind: 'ENUM', 35 153 name: 'PokemonType', 36 154 ofType: null, 37 155 }, 156 + isDeprecated: false, 157 + deprecationReason: null, 158 + }, 159 + { 160 + name: 'damage', 161 + description: null, 38 162 args: [], 163 + type: { 164 + kind: 'SCALAR', 165 + name: 'Int', 166 + ofType: null, 167 + }, 168 + isDeprecated: false, 169 + deprecationReason: null, 39 170 }, 40 171 ], 172 + inputFields: null, 41 173 interfaces: [], 174 + enumValues: null, 175 + possibleTypes: null, 42 176 }, 43 177 { 44 178 kind: 'SCALAR', 45 - name: 'Int', 179 + name: 'String', 180 + description: 181 + 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', 182 + fields: null, 183 + inputFields: null, 184 + interfaces: null, 185 + enumValues: null, 186 + possibleTypes: null, 46 187 }, 47 188 { 48 189 kind: 'SCALAR', 49 - name: 'String', 190 + name: 'Int', 191 + description: 192 + 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', 193 + fields: null, 194 + inputFields: null, 195 + interfaces: null, 196 + enumValues: null, 197 + possibleTypes: null, 198 + }, 199 + { 200 + kind: 'OBJECT', 201 + name: 'EvolutionRequirement', 202 + description: 203 + 'Requirement that prevents an evolution through regular means of levelling up.', 204 + fields: [ 205 + { 206 + name: 'amount', 207 + description: null, 208 + args: [], 209 + type: { 210 + kind: 'SCALAR', 211 + name: 'Int', 212 + ofType: null, 213 + }, 214 + isDeprecated: false, 215 + deprecationReason: null, 216 + }, 217 + { 218 + name: 'name', 219 + description: null, 220 + args: [], 221 + type: { 222 + kind: 'SCALAR', 223 + name: 'String', 224 + ofType: null, 225 + }, 226 + isDeprecated: false, 227 + deprecationReason: null, 228 + }, 229 + ], 230 + inputFields: null, 231 + interfaces: [], 232 + enumValues: null, 233 + possibleTypes: null, 234 + }, 235 + { 236 + kind: 'OBJECT', 237 + name: 'PokemonDimension', 238 + description: null, 239 + fields: [ 240 + { 241 + name: 'minimum', 242 + description: null, 243 + args: [], 244 + type: { 245 + kind: 'SCALAR', 246 + name: 'String', 247 + ofType: null, 248 + }, 249 + isDeprecated: false, 250 + deprecationReason: null, 251 + }, 252 + { 253 + name: 'maximum', 254 + description: null, 255 + args: [], 256 + type: { 257 + kind: 'SCALAR', 258 + name: 'String', 259 + ofType: null, 260 + }, 261 + isDeprecated: false, 262 + deprecationReason: null, 263 + }, 264 + ], 265 + inputFields: null, 266 + interfaces: [], 267 + enumValues: null, 268 + possibleTypes: null, 50 269 }, 51 270 { 52 271 kind: 'OBJECT', 53 272 name: 'AttacksConnection', 273 + description: null, 54 274 fields: [ 55 275 { 56 276 name: 'fast', 277 + description: null, 278 + args: [], 57 279 type: { 58 280 kind: 'LIST', 281 + name: null, 59 282 ofType: { 60 283 kind: 'OBJECT', 61 284 name: 'Attack', 62 285 ofType: null, 63 286 }, 64 287 }, 65 - args: [], 288 + isDeprecated: false, 289 + deprecationReason: null, 66 290 }, 67 291 { 68 292 name: 'special', 293 + description: null, 294 + args: [], 69 295 type: { 70 296 kind: 'LIST', 297 + name: null, 71 298 ofType: { 72 299 kind: 'OBJECT', 73 300 name: 'Attack', 74 301 ofType: null, 75 302 }, 76 303 }, 77 - args: [], 304 + isDeprecated: false, 305 + deprecationReason: null, 78 306 }, 79 307 ], 308 + inputFields: null, 80 309 interfaces: [], 310 + enumValues: null, 311 + possibleTypes: null, 81 312 }, 82 313 { 83 314 kind: 'OBJECT', 84 - name: 'EvolutionRequirement', 315 + name: 'Pokemon', 316 + description: null, 85 317 fields: [ 86 318 { 87 - name: 'amount', 319 + name: 'id', 320 + description: null, 321 + args: [], 88 322 type: { 89 - kind: 'SCALAR', 90 - name: 'Int', 91 - ofType: null, 323 + kind: 'NON_NULL', 324 + name: null, 325 + ofType: { 326 + kind: 'SCALAR', 327 + name: 'ID', 328 + ofType: null, 329 + }, 92 330 }, 93 - args: [], 331 + isDeprecated: false, 332 + deprecationReason: null, 94 333 }, 95 334 { 96 335 name: 'name', 336 + description: null, 337 + args: [], 338 + type: { 339 + kind: 'NON_NULL', 340 + name: null, 341 + ofType: { 342 + kind: 'SCALAR', 343 + name: 'String', 344 + ofType: null, 345 + }, 346 + }, 347 + isDeprecated: false, 348 + deprecationReason: null, 349 + }, 350 + { 351 + name: 'classification', 352 + description: null, 353 + args: [], 97 354 type: { 98 355 kind: 'SCALAR', 99 356 name: 'String', 100 357 ofType: null, 101 358 }, 359 + isDeprecated: false, 360 + deprecationReason: null, 361 + }, 362 + { 363 + name: 'types', 364 + description: null, 102 365 args: [], 366 + type: { 367 + kind: 'LIST', 368 + name: null, 369 + ofType: { 370 + kind: 'ENUM', 371 + name: 'PokemonType', 372 + ofType: null, 373 + }, 374 + }, 375 + isDeprecated: false, 376 + deprecationReason: null, 103 377 }, 104 - ], 105 - interfaces: [], 106 - }, 107 - { 108 - kind: 'OBJECT', 109 - name: 'Pokemon', 110 - fields: [ 378 + { 379 + name: 'resistant', 380 + description: null, 381 + args: [], 382 + type: { 383 + kind: 'LIST', 384 + name: null, 385 + ofType: { 386 + kind: 'ENUM', 387 + name: 'PokemonType', 388 + ofType: null, 389 + }, 390 + }, 391 + isDeprecated: false, 392 + deprecationReason: null, 393 + }, 394 + { 395 + name: 'weaknesses', 396 + description: null, 397 + args: [], 398 + type: { 399 + kind: 'LIST', 400 + name: null, 401 + ofType: { 402 + kind: 'ENUM', 403 + name: 'PokemonType', 404 + ofType: null, 405 + }, 406 + }, 407 + isDeprecated: false, 408 + deprecationReason: null, 409 + }, 410 + { 411 + name: 'evolutionRequirements', 412 + description: null, 413 + args: [], 414 + type: { 415 + kind: 'LIST', 416 + name: null, 417 + ofType: { 418 + kind: 'OBJECT', 419 + name: 'EvolutionRequirement', 420 + ofType: null, 421 + }, 422 + }, 423 + isDeprecated: false, 424 + deprecationReason: null, 425 + }, 426 + { 427 + name: 'weight', 428 + description: null, 429 + args: [], 430 + type: { 431 + kind: 'OBJECT', 432 + name: 'PokemonDimension', 433 + ofType: null, 434 + }, 435 + isDeprecated: false, 436 + deprecationReason: null, 437 + }, 438 + { 439 + name: 'height', 440 + description: null, 441 + args: [], 442 + type: { 443 + kind: 'OBJECT', 444 + name: 'PokemonDimension', 445 + ofType: null, 446 + }, 447 + isDeprecated: false, 448 + deprecationReason: null, 449 + }, 111 450 { 112 451 name: 'attacks', 452 + description: null, 453 + args: [], 113 454 type: { 114 455 kind: 'OBJECT', 115 456 name: 'AttacksConnection', 116 457 ofType: null, 117 458 }, 459 + isDeprecated: false, 460 + deprecationReason: null, 461 + }, 462 + { 463 + name: 'fleeRate', 464 + description: 'Likelihood of an attempt to catch a Pokémon to fail.', 118 465 args: [], 466 + type: { 467 + kind: 'SCALAR', 468 + name: 'Float', 469 + ofType: null, 470 + }, 471 + isDeprecated: false, 472 + deprecationReason: null, 119 473 }, 120 474 { 121 - name: 'classification', 475 + name: 'maxCP', 476 + description: 477 + 'Maximum combat power a Pokémon may achieve at max level.', 478 + args: [], 122 479 type: { 123 480 kind: 'SCALAR', 124 - name: 'String', 481 + name: 'Int', 125 482 ofType: null, 126 483 }, 484 + isDeprecated: false, 485 + deprecationReason: null, 486 + }, 487 + { 488 + name: 'maxHP', 489 + description: 490 + 'Maximum health points a Pokémon may achieve at max level.', 127 491 args: [], 492 + type: { 493 + kind: 'SCALAR', 494 + name: 'Int', 495 + ofType: null, 496 + }, 497 + isDeprecated: false, 498 + deprecationReason: null, 128 499 }, 129 500 { 130 - name: 'evolutionRequirements', 501 + name: 'evolutions', 502 + description: null, 503 + args: [], 131 504 type: { 132 505 kind: 'LIST', 506 + name: null, 133 507 ofType: { 134 508 kind: 'OBJECT', 135 - name: 'EvolutionRequirement', 509 + name: 'Pokemon', 136 510 ofType: null, 137 511 }, 138 512 }, 139 - args: [], 513 + isDeprecated: false, 514 + deprecationReason: null, 140 515 }, 516 + ], 517 + inputFields: null, 518 + interfaces: [], 519 + enumValues: null, 520 + possibleTypes: null, 521 + }, 522 + { 523 + kind: 'SCALAR', 524 + name: 'ID', 525 + description: 526 + 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', 527 + fields: null, 528 + inputFields: null, 529 + interfaces: null, 530 + enumValues: null, 531 + possibleTypes: null, 532 + }, 533 + { 534 + kind: 'SCALAR', 535 + name: 'Float', 536 + description: 537 + 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', 538 + fields: null, 539 + inputFields: null, 540 + interfaces: null, 541 + enumValues: null, 542 + possibleTypes: null, 543 + }, 544 + { 545 + kind: 'OBJECT', 546 + name: 'Query', 547 + description: null, 548 + fields: [ 141 549 { 142 - name: 'evolutions', 550 + name: 'pokemons', 551 + description: 'List out all Pokémon, optionally in pages', 552 + args: [ 553 + { 554 + name: 'limit', 555 + description: null, 556 + type: { 557 + kind: 'SCALAR', 558 + name: 'Int', 559 + ofType: null, 560 + }, 561 + defaultValue: null, 562 + }, 563 + { 564 + name: 'skip', 565 + description: null, 566 + type: { 567 + kind: 'SCALAR', 568 + name: 'Int', 569 + ofType: null, 570 + }, 571 + defaultValue: null, 572 + }, 573 + ], 143 574 type: { 144 575 kind: 'LIST', 576 + name: null, 145 577 ofType: { 146 578 kind: 'OBJECT', 147 579 name: 'Pokemon', 148 580 ofType: null, 149 581 }, 150 582 }, 151 - args: [], 583 + isDeprecated: false, 584 + deprecationReason: null, 585 + }, 586 + { 587 + name: 'pokemon', 588 + description: 589 + 'Get a single Pokémon by its ID, a three character long identifier padded with zeroes', 590 + args: [ 591 + { 592 + name: 'id', 593 + description: null, 594 + type: { 595 + kind: 'NON_NULL', 596 + name: null, 597 + ofType: { 598 + kind: 'SCALAR', 599 + name: 'ID', 600 + ofType: null, 601 + }, 602 + }, 603 + defaultValue: null, 604 + }, 605 + ], 606 + type: { 607 + kind: 'OBJECT', 608 + name: 'Pokemon', 609 + ofType: null, 610 + }, 611 + isDeprecated: false, 612 + deprecationReason: null, 152 613 }, 614 + ], 615 + inputFields: null, 616 + interfaces: [], 617 + enumValues: null, 618 + possibleTypes: null, 619 + }, 620 + { 621 + kind: 'SCALAR', 622 + name: 'Boolean', 623 + description: 'The `Boolean` scalar type represents `true` or `false`.', 624 + fields: null, 625 + inputFields: null, 626 + interfaces: null, 627 + enumValues: null, 628 + possibleTypes: null, 629 + }, 630 + { 631 + kind: 'OBJECT', 632 + name: '__Schema', 633 + description: 634 + 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', 635 + fields: [ 153 636 { 154 - name: 'fleeRate', 637 + name: 'description', 638 + description: null, 639 + args: [], 155 640 type: { 156 641 kind: 'SCALAR', 157 - name: 'Float', 642 + name: 'String', 158 643 ofType: null, 159 644 }, 645 + isDeprecated: false, 646 + deprecationReason: null, 647 + }, 648 + { 649 + name: 'types', 650 + description: 'A list of all types supported by this server.', 160 651 args: [], 652 + type: { 653 + kind: 'NON_NULL', 654 + name: null, 655 + ofType: { 656 + kind: 'LIST', 657 + name: null, 658 + ofType: { 659 + kind: 'NON_NULL', 660 + name: null, 661 + ofType: { 662 + kind: 'OBJECT', 663 + name: '__Type', 664 + ofType: null, 665 + }, 666 + }, 667 + }, 668 + }, 669 + isDeprecated: false, 670 + deprecationReason: null, 161 671 }, 162 672 { 163 - name: 'height', 673 + name: 'queryType', 674 + description: 'The type that query operations will be rooted at.', 675 + args: [], 676 + type: { 677 + kind: 'NON_NULL', 678 + name: null, 679 + ofType: { 680 + kind: 'OBJECT', 681 + name: '__Type', 682 + ofType: null, 683 + }, 684 + }, 685 + isDeprecated: false, 686 + deprecationReason: null, 687 + }, 688 + { 689 + name: 'mutationType', 690 + description: 691 + 'If this server supports mutation, the type that mutation operations will be rooted at.', 692 + args: [], 164 693 type: { 165 694 kind: 'OBJECT', 166 - name: 'PokemonDimension', 695 + name: '__Type', 167 696 ofType: null, 168 697 }, 698 + isDeprecated: false, 699 + deprecationReason: null, 700 + }, 701 + { 702 + name: 'subscriptionType', 703 + description: 704 + 'If this server support subscription, the type that subscription operations will be rooted at.', 169 705 args: [], 706 + type: { 707 + kind: 'OBJECT', 708 + name: '__Type', 709 + ofType: null, 710 + }, 711 + isDeprecated: false, 712 + deprecationReason: null, 170 713 }, 171 714 { 172 - name: 'id', 715 + name: 'directives', 716 + description: 'A list of all directives supported by this server.', 717 + args: [], 173 718 type: { 174 719 kind: 'NON_NULL', 720 + name: null, 175 721 ofType: { 176 - kind: 'SCALAR', 177 - name: 'ID', 178 - ofType: null, 722 + kind: 'LIST', 723 + name: null, 724 + ofType: { 725 + kind: 'NON_NULL', 726 + name: null, 727 + ofType: { 728 + kind: 'OBJECT', 729 + name: '__Directive', 730 + ofType: null, 731 + }, 732 + }, 179 733 }, 180 734 }, 735 + isDeprecated: false, 736 + deprecationReason: null, 737 + }, 738 + ], 739 + inputFields: null, 740 + interfaces: [], 741 + enumValues: null, 742 + possibleTypes: null, 743 + }, 744 + { 745 + kind: 'OBJECT', 746 + name: '__Type', 747 + description: 748 + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', 749 + fields: [ 750 + { 751 + name: 'kind', 752 + description: null, 181 753 args: [], 754 + type: { 755 + kind: 'NON_NULL', 756 + name: null, 757 + ofType: { 758 + kind: 'ENUM', 759 + name: '__TypeKind', 760 + ofType: null, 761 + }, 762 + }, 763 + isDeprecated: false, 764 + deprecationReason: null, 182 765 }, 183 766 { 184 - name: 'maxCP', 767 + name: 'name', 768 + description: null, 769 + args: [], 185 770 type: { 186 771 kind: 'SCALAR', 187 - name: 'Int', 772 + name: 'String', 188 773 ofType: null, 189 774 }, 775 + isDeprecated: false, 776 + deprecationReason: null, 777 + }, 778 + { 779 + name: 'description', 780 + description: null, 190 781 args: [], 782 + type: { 783 + kind: 'SCALAR', 784 + name: 'String', 785 + ofType: null, 786 + }, 787 + isDeprecated: false, 788 + deprecationReason: null, 191 789 }, 192 790 { 193 - name: 'maxHP', 791 + name: 'specifiedByUrl', 792 + description: null, 793 + args: [], 194 794 type: { 195 795 kind: 'SCALAR', 196 - name: 'Int', 796 + name: 'String', 197 797 ofType: null, 198 798 }, 799 + isDeprecated: false, 800 + deprecationReason: null, 801 + }, 802 + { 803 + name: 'fields', 804 + description: null, 805 + args: [ 806 + { 807 + name: 'includeDeprecated', 808 + description: null, 809 + type: { 810 + kind: 'SCALAR', 811 + name: 'Boolean', 812 + ofType: null, 813 + }, 814 + defaultValue: 'false', 815 + }, 816 + ], 817 + type: { 818 + kind: 'LIST', 819 + name: null, 820 + ofType: { 821 + kind: 'NON_NULL', 822 + name: null, 823 + ofType: { 824 + kind: 'OBJECT', 825 + name: '__Field', 826 + ofType: null, 827 + }, 828 + }, 829 + }, 830 + isDeprecated: false, 831 + deprecationReason: null, 832 + }, 833 + { 834 + name: 'interfaces', 835 + description: null, 199 836 args: [], 837 + type: { 838 + kind: 'LIST', 839 + name: null, 840 + ofType: { 841 + kind: 'NON_NULL', 842 + name: null, 843 + ofType: { 844 + kind: 'OBJECT', 845 + name: '__Type', 846 + ofType: null, 847 + }, 848 + }, 849 + }, 850 + isDeprecated: false, 851 + deprecationReason: null, 200 852 }, 201 853 { 854 + name: 'possibleTypes', 855 + description: null, 856 + args: [], 857 + type: { 858 + kind: 'LIST', 859 + name: null, 860 + ofType: { 861 + kind: 'NON_NULL', 862 + name: null, 863 + ofType: { 864 + kind: 'OBJECT', 865 + name: '__Type', 866 + ofType: null, 867 + }, 868 + }, 869 + }, 870 + isDeprecated: false, 871 + deprecationReason: null, 872 + }, 873 + { 874 + name: 'enumValues', 875 + description: null, 876 + args: [ 877 + { 878 + name: 'includeDeprecated', 879 + description: null, 880 + type: { 881 + kind: 'SCALAR', 882 + name: 'Boolean', 883 + ofType: null, 884 + }, 885 + defaultValue: 'false', 886 + }, 887 + ], 888 + type: { 889 + kind: 'LIST', 890 + name: null, 891 + ofType: { 892 + kind: 'NON_NULL', 893 + name: null, 894 + ofType: { 895 + kind: 'OBJECT', 896 + name: '__EnumValue', 897 + ofType: null, 898 + }, 899 + }, 900 + }, 901 + isDeprecated: false, 902 + deprecationReason: null, 903 + }, 904 + { 905 + name: 'inputFields', 906 + description: null, 907 + args: [ 908 + { 909 + name: 'includeDeprecated', 910 + description: null, 911 + type: { 912 + kind: 'SCALAR', 913 + name: 'Boolean', 914 + ofType: null, 915 + }, 916 + defaultValue: 'false', 917 + }, 918 + ], 919 + type: { 920 + kind: 'LIST', 921 + name: null, 922 + ofType: { 923 + kind: 'NON_NULL', 924 + name: null, 925 + ofType: { 926 + kind: 'OBJECT', 927 + name: '__InputValue', 928 + ofType: null, 929 + }, 930 + }, 931 + }, 932 + isDeprecated: false, 933 + deprecationReason: null, 934 + }, 935 + { 936 + name: 'ofType', 937 + description: null, 938 + args: [], 939 + type: { 940 + kind: 'OBJECT', 941 + name: '__Type', 942 + ofType: null, 943 + }, 944 + isDeprecated: false, 945 + deprecationReason: null, 946 + }, 947 + ], 948 + inputFields: null, 949 + interfaces: [], 950 + enumValues: null, 951 + possibleTypes: null, 952 + }, 953 + { 954 + kind: 'ENUM', 955 + name: '__TypeKind', 956 + description: 957 + 'An enum describing what kind of type a given `__Type` is.', 958 + fields: null, 959 + inputFields: null, 960 + interfaces: null, 961 + enumValues: [ 962 + { 963 + name: 'SCALAR', 964 + description: 'Indicates this type is a scalar.', 965 + isDeprecated: false, 966 + deprecationReason: null, 967 + }, 968 + { 969 + name: 'OBJECT', 970 + description: 971 + 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', 972 + isDeprecated: false, 973 + deprecationReason: null, 974 + }, 975 + { 976 + name: 'INTERFACE', 977 + description: 978 + 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', 979 + isDeprecated: false, 980 + deprecationReason: null, 981 + }, 982 + { 983 + name: 'UNION', 984 + description: 985 + 'Indicates this type is a union. `possibleTypes` is a valid field.', 986 + isDeprecated: false, 987 + deprecationReason: null, 988 + }, 989 + { 990 + name: 'ENUM', 991 + description: 992 + 'Indicates this type is an enum. `enumValues` is a valid field.', 993 + isDeprecated: false, 994 + deprecationReason: null, 995 + }, 996 + { 997 + name: 'INPUT_OBJECT', 998 + description: 999 + 'Indicates this type is an input object. `inputFields` is a valid field.', 1000 + isDeprecated: false, 1001 + deprecationReason: null, 1002 + }, 1003 + { 1004 + name: 'LIST', 1005 + description: 1006 + 'Indicates this type is a list. `ofType` is a valid field.', 1007 + isDeprecated: false, 1008 + deprecationReason: null, 1009 + }, 1010 + { 1011 + name: 'NON_NULL', 1012 + description: 1013 + 'Indicates this type is a non-null. `ofType` is a valid field.', 1014 + isDeprecated: false, 1015 + deprecationReason: null, 1016 + }, 1017 + ], 1018 + possibleTypes: null, 1019 + }, 1020 + { 1021 + kind: 'OBJECT', 1022 + name: '__Field', 1023 + description: 1024 + 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', 1025 + fields: [ 1026 + { 202 1027 name: 'name', 1028 + description: null, 1029 + args: [], 203 1030 type: { 204 1031 kind: 'NON_NULL', 1032 + name: null, 205 1033 ofType: { 206 1034 kind: 'SCALAR', 207 1035 name: 'String', 208 1036 ofType: null, 209 1037 }, 210 1038 }, 1039 + isDeprecated: false, 1040 + deprecationReason: null, 1041 + }, 1042 + { 1043 + name: 'description', 1044 + description: null, 211 1045 args: [], 1046 + type: { 1047 + kind: 'SCALAR', 1048 + name: 'String', 1049 + ofType: null, 1050 + }, 1051 + isDeprecated: false, 1052 + deprecationReason: null, 212 1053 }, 213 1054 { 214 - name: 'resistant', 1055 + name: 'args', 1056 + description: null, 1057 + args: [ 1058 + { 1059 + name: 'includeDeprecated', 1060 + description: null, 1061 + type: { 1062 + kind: 'SCALAR', 1063 + name: 'Boolean', 1064 + ofType: null, 1065 + }, 1066 + defaultValue: 'false', 1067 + }, 1068 + ], 1069 + type: { 1070 + kind: 'NON_NULL', 1071 + name: null, 1072 + ofType: { 1073 + kind: 'LIST', 1074 + name: null, 1075 + ofType: { 1076 + kind: 'NON_NULL', 1077 + name: null, 1078 + ofType: { 1079 + kind: 'OBJECT', 1080 + name: '__InputValue', 1081 + ofType: null, 1082 + }, 1083 + }, 1084 + }, 1085 + }, 1086 + isDeprecated: false, 1087 + deprecationReason: null, 1088 + }, 1089 + { 1090 + name: 'type', 1091 + description: null, 1092 + args: [], 215 1093 type: { 216 - kind: 'LIST', 1094 + kind: 'NON_NULL', 1095 + name: null, 217 1096 ofType: { 218 - kind: 'ENUM', 219 - name: 'PokemonType', 1097 + kind: 'OBJECT', 1098 + name: '__Type', 220 1099 ofType: null, 221 1100 }, 222 1101 }, 223 - args: [], 1102 + isDeprecated: false, 1103 + deprecationReason: null, 224 1104 }, 225 1105 { 226 - name: 'types', 1106 + name: 'isDeprecated', 1107 + description: null, 1108 + args: [], 227 1109 type: { 228 - kind: 'LIST', 1110 + kind: 'NON_NULL', 1111 + name: null, 229 1112 ofType: { 230 - kind: 'ENUM', 231 - name: 'PokemonType', 1113 + kind: 'SCALAR', 1114 + name: 'Boolean', 232 1115 ofType: null, 233 1116 }, 234 1117 }, 1118 + isDeprecated: false, 1119 + deprecationReason: null, 1120 + }, 1121 + { 1122 + name: 'deprecationReason', 1123 + description: null, 235 1124 args: [], 1125 + type: { 1126 + kind: 'SCALAR', 1127 + name: 'String', 1128 + ofType: null, 1129 + }, 1130 + isDeprecated: false, 1131 + deprecationReason: null, 236 1132 }, 1133 + ], 1134 + inputFields: null, 1135 + interfaces: [], 1136 + enumValues: null, 1137 + possibleTypes: null, 1138 + }, 1139 + { 1140 + kind: 'OBJECT', 1141 + name: '__InputValue', 1142 + description: 1143 + 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', 1144 + fields: [ 237 1145 { 238 - name: 'weaknesses', 1146 + name: 'name', 1147 + description: null, 1148 + args: [], 239 1149 type: { 240 - kind: 'LIST', 1150 + kind: 'NON_NULL', 1151 + name: null, 241 1152 ofType: { 242 - kind: 'ENUM', 243 - name: 'PokemonType', 1153 + kind: 'SCALAR', 1154 + name: 'String', 244 1155 ofType: null, 245 1156 }, 246 1157 }, 1158 + isDeprecated: false, 1159 + deprecationReason: null, 1160 + }, 1161 + { 1162 + name: 'description', 1163 + description: null, 247 1164 args: [], 1165 + type: { 1166 + kind: 'SCALAR', 1167 + name: 'String', 1168 + ofType: null, 1169 + }, 1170 + isDeprecated: false, 1171 + deprecationReason: null, 248 1172 }, 249 1173 { 250 - name: 'weight', 1174 + name: 'type', 1175 + description: null, 1176 + args: [], 1177 + type: { 1178 + kind: 'NON_NULL', 1179 + name: null, 1180 + ofType: { 1181 + kind: 'OBJECT', 1182 + name: '__Type', 1183 + ofType: null, 1184 + }, 1185 + }, 1186 + isDeprecated: false, 1187 + deprecationReason: null, 1188 + }, 1189 + { 1190 + name: 'defaultValue', 1191 + description: 1192 + 'A GraphQL-formatted string representing the default value for this input value.', 1193 + args: [], 251 1194 type: { 252 - kind: 'OBJECT', 253 - name: 'PokemonDimension', 1195 + kind: 'SCALAR', 1196 + name: 'String', 254 1197 ofType: null, 255 1198 }, 1199 + isDeprecated: false, 1200 + deprecationReason: null, 1201 + }, 1202 + { 1203 + name: 'isDeprecated', 1204 + description: null, 256 1205 args: [], 1206 + type: { 1207 + kind: 'NON_NULL', 1208 + name: null, 1209 + ofType: { 1210 + kind: 'SCALAR', 1211 + name: 'Boolean', 1212 + ofType: null, 1213 + }, 1214 + }, 1215 + isDeprecated: false, 1216 + deprecationReason: null, 1217 + }, 1218 + { 1219 + name: 'deprecationReason', 1220 + description: null, 1221 + args: [], 1222 + type: { 1223 + kind: 'SCALAR', 1224 + name: 'String', 1225 + ofType: null, 1226 + }, 1227 + isDeprecated: false, 1228 + deprecationReason: null, 257 1229 }, 258 1230 ], 1231 + inputFields: null, 259 1232 interfaces: [], 260 - }, 261 - { 262 - kind: 'SCALAR', 263 - name: 'Float', 264 - }, 265 - { 266 - kind: 'SCALAR', 267 - name: 'ID', 1233 + enumValues: null, 1234 + possibleTypes: null, 268 1235 }, 269 1236 { 270 1237 kind: 'OBJECT', 271 - name: 'PokemonDimension', 1238 + name: '__EnumValue', 1239 + description: 1240 + 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', 272 1241 fields: [ 273 1242 { 274 - name: 'maximum', 1243 + name: 'name', 1244 + description: null, 1245 + args: [], 1246 + type: { 1247 + kind: 'NON_NULL', 1248 + name: null, 1249 + ofType: { 1250 + kind: 'SCALAR', 1251 + name: 'String', 1252 + ofType: null, 1253 + }, 1254 + }, 1255 + isDeprecated: false, 1256 + deprecationReason: null, 1257 + }, 1258 + { 1259 + name: 'description', 1260 + description: null, 1261 + args: [], 275 1262 type: { 276 1263 kind: 'SCALAR', 277 1264 name: 'String', 278 1265 ofType: null, 279 1266 }, 1267 + isDeprecated: false, 1268 + deprecationReason: null, 1269 + }, 1270 + { 1271 + name: 'isDeprecated', 1272 + description: null, 280 1273 args: [], 1274 + type: { 1275 + kind: 'NON_NULL', 1276 + name: null, 1277 + ofType: { 1278 + kind: 'SCALAR', 1279 + name: 'Boolean', 1280 + ofType: null, 1281 + }, 1282 + }, 1283 + isDeprecated: false, 1284 + deprecationReason: null, 281 1285 }, 282 1286 { 283 - name: 'minimum', 1287 + name: 'deprecationReason', 1288 + description: null, 1289 + args: [], 1290 + type: { 1291 + kind: 'SCALAR', 1292 + name: 'String', 1293 + ofType: null, 1294 + }, 1295 + isDeprecated: false, 1296 + deprecationReason: null, 1297 + }, 1298 + ], 1299 + inputFields: null, 1300 + interfaces: [], 1301 + enumValues: null, 1302 + possibleTypes: null, 1303 + }, 1304 + { 1305 + kind: 'OBJECT', 1306 + name: '__Directive', 1307 + description: 1308 + "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", 1309 + fields: [ 1310 + { 1311 + name: 'name', 1312 + description: null, 1313 + args: [], 1314 + type: { 1315 + kind: 'NON_NULL', 1316 + name: null, 1317 + ofType: { 1318 + kind: 'SCALAR', 1319 + name: 'String', 1320 + ofType: null, 1321 + }, 1322 + }, 1323 + isDeprecated: false, 1324 + deprecationReason: null, 1325 + }, 1326 + { 1327 + name: 'description', 1328 + description: null, 1329 + args: [], 284 1330 type: { 285 1331 kind: 'SCALAR', 286 1332 name: 'String', 287 1333 ofType: null, 288 1334 }, 1335 + isDeprecated: false, 1336 + deprecationReason: null, 1337 + }, 1338 + { 1339 + name: 'isRepeatable', 1340 + description: null, 289 1341 args: [], 1342 + type: { 1343 + kind: 'NON_NULL', 1344 + name: null, 1345 + ofType: { 1346 + kind: 'SCALAR', 1347 + name: 'Boolean', 1348 + ofType: null, 1349 + }, 1350 + }, 1351 + isDeprecated: false, 1352 + deprecationReason: null, 1353 + }, 1354 + { 1355 + name: 'locations', 1356 + description: null, 1357 + args: [], 1358 + type: { 1359 + kind: 'NON_NULL', 1360 + name: null, 1361 + ofType: { 1362 + kind: 'LIST', 1363 + name: null, 1364 + ofType: { 1365 + kind: 'NON_NULL', 1366 + name: null, 1367 + ofType: { 1368 + kind: 'ENUM', 1369 + name: '__DirectiveLocation', 1370 + ofType: null, 1371 + }, 1372 + }, 1373 + }, 1374 + }, 1375 + isDeprecated: false, 1376 + deprecationReason: null, 1377 + }, 1378 + { 1379 + name: 'args', 1380 + description: null, 1381 + args: [], 1382 + type: { 1383 + kind: 'NON_NULL', 1384 + name: null, 1385 + ofType: { 1386 + kind: 'LIST', 1387 + name: null, 1388 + ofType: { 1389 + kind: 'NON_NULL', 1390 + name: null, 1391 + ofType: { 1392 + kind: 'OBJECT', 1393 + name: '__InputValue', 1394 + ofType: null, 1395 + }, 1396 + }, 1397 + }, 1398 + }, 1399 + isDeprecated: false, 1400 + deprecationReason: null, 290 1401 }, 291 1402 ], 1403 + inputFields: null, 292 1404 interfaces: [], 1405 + enumValues: null, 1406 + possibleTypes: null, 293 1407 }, 294 1408 { 295 1409 kind: 'ENUM', 296 - name: 'PokemonType', 1410 + name: '__DirectiveLocation', 1411 + description: 1412 + 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', 1413 + fields: null, 1414 + inputFields: null, 1415 + interfaces: null, 297 1416 enumValues: [ 298 1417 { 299 - name: 'Bug', 1418 + name: 'QUERY', 1419 + description: 'Location adjacent to a query operation.', 1420 + isDeprecated: false, 1421 + deprecationReason: null, 300 1422 }, 301 1423 { 302 - name: 'Dark', 1424 + name: 'MUTATION', 1425 + description: 'Location adjacent to a mutation operation.', 1426 + isDeprecated: false, 1427 + deprecationReason: null, 303 1428 }, 304 1429 { 305 - name: 'Dragon', 1430 + name: 'SUBSCRIPTION', 1431 + description: 'Location adjacent to a subscription operation.', 1432 + isDeprecated: false, 1433 + deprecationReason: null, 306 1434 }, 307 1435 { 308 - name: 'Electric', 1436 + name: 'FIELD', 1437 + description: 'Location adjacent to a field.', 1438 + isDeprecated: false, 1439 + deprecationReason: null, 309 1440 }, 310 1441 { 311 - name: 'Fairy', 1442 + name: 'FRAGMENT_DEFINITION', 1443 + description: 'Location adjacent to a fragment definition.', 1444 + isDeprecated: false, 1445 + deprecationReason: null, 312 1446 }, 313 1447 { 314 - name: 'Fighting', 1448 + name: 'FRAGMENT_SPREAD', 1449 + description: 'Location adjacent to a fragment spread.', 1450 + isDeprecated: false, 1451 + deprecationReason: null, 315 1452 }, 316 1453 { 317 - name: 'Fire', 1454 + name: 'INLINE_FRAGMENT', 1455 + description: 'Location adjacent to an inline fragment.', 1456 + isDeprecated: false, 1457 + deprecationReason: null, 318 1458 }, 319 1459 { 320 - name: 'Flying', 1460 + name: 'VARIABLE_DEFINITION', 1461 + description: 'Location adjacent to a variable definition.', 1462 + isDeprecated: false, 1463 + deprecationReason: null, 321 1464 }, 322 1465 { 323 - name: 'Ghost', 1466 + name: 'SCHEMA', 1467 + description: 'Location adjacent to a schema definition.', 1468 + isDeprecated: false, 1469 + deprecationReason: null, 324 1470 }, 325 1471 { 326 - name: 'Grass', 1472 + name: 'SCALAR', 1473 + description: 'Location adjacent to a scalar definition.', 1474 + isDeprecated: false, 1475 + deprecationReason: null, 327 1476 }, 328 1477 { 329 - name: 'Ground', 1478 + name: 'OBJECT', 1479 + description: 'Location adjacent to an object type definition.', 1480 + isDeprecated: false, 1481 + deprecationReason: null, 1482 + }, 1483 + { 1484 + name: 'FIELD_DEFINITION', 1485 + description: 'Location adjacent to a field definition.', 1486 + isDeprecated: false, 1487 + deprecationReason: null, 330 1488 }, 331 1489 { 332 - name: 'Ice', 1490 + name: 'ARGUMENT_DEFINITION', 1491 + description: 'Location adjacent to an argument definition.', 1492 + isDeprecated: false, 1493 + deprecationReason: null, 333 1494 }, 334 1495 { 335 - name: 'Normal', 1496 + name: 'INTERFACE', 1497 + description: 'Location adjacent to an interface definition.', 1498 + isDeprecated: false, 1499 + deprecationReason: null, 336 1500 }, 337 1501 { 338 - name: 'Poison', 1502 + name: 'UNION', 1503 + description: 'Location adjacent to a union definition.', 1504 + isDeprecated: false, 1505 + deprecationReason: null, 339 1506 }, 340 1507 { 341 - name: 'Psychic', 1508 + name: 'ENUM', 1509 + description: 'Location adjacent to an enum definition.', 1510 + isDeprecated: false, 1511 + deprecationReason: null, 342 1512 }, 343 1513 { 344 - name: 'Rock', 1514 + name: 'ENUM_VALUE', 1515 + description: 'Location adjacent to an enum value definition.', 1516 + isDeprecated: false, 1517 + deprecationReason: null, 345 1518 }, 346 1519 { 347 - name: 'Steel', 1520 + name: 'INPUT_OBJECT', 1521 + description: 1522 + 'Location adjacent to an input object type definition.', 1523 + isDeprecated: false, 1524 + deprecationReason: null, 348 1525 }, 349 1526 { 350 - name: 'Water', 1527 + name: 'INPUT_FIELD_DEFINITION', 1528 + description: 1529 + 'Location adjacent to an input object field definition.', 1530 + isDeprecated: false, 1531 + deprecationReason: null, 351 1532 }, 352 1533 ], 1534 + possibleTypes: null, 353 1535 }, 1536 + ], 1537 + directives: [ 354 1538 { 355 - kind: 'OBJECT', 356 - name: 'Query', 357 - fields: [ 1539 + name: 'include', 1540 + description: 1541 + 'Directs the executor to include this field or fragment only when the `if` argument is true.', 1542 + locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'], 1543 + args: [ 358 1544 { 359 - name: 'pokemon', 1545 + name: 'if', 1546 + description: 'Included when true.', 360 1547 type: { 361 - kind: 'OBJECT', 362 - name: 'Pokemon', 363 - ofType: null, 364 - }, 365 - args: [ 366 - { 367 - name: 'id', 368 - type: { 369 - kind: 'NON_NULL', 370 - ofType: { 371 - kind: 'SCALAR', 372 - name: 'ID', 373 - ofType: null, 374 - }, 375 - }, 1548 + kind: 'NON_NULL', 1549 + name: null, 1550 + ofType: { 1551 + kind: 'SCALAR', 1552 + name: 'Boolean', 1553 + ofType: null, 376 1554 }, 377 - ], 1555 + }, 1556 + defaultValue: null, 378 1557 }, 1558 + ], 1559 + }, 1560 + { 1561 + name: 'skip', 1562 + description: 1563 + 'Directs the executor to skip this field or fragment when the `if` argument is true.', 1564 + locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'], 1565 + args: [ 379 1566 { 380 - name: 'pokemons', 1567 + name: 'if', 1568 + description: 'Skipped when true.', 381 1569 type: { 382 - kind: 'LIST', 1570 + kind: 'NON_NULL', 1571 + name: null, 383 1572 ofType: { 384 - kind: 'OBJECT', 385 - name: 'Pokemon', 1573 + kind: 'SCALAR', 1574 + name: 'Boolean', 386 1575 ofType: null, 387 1576 }, 388 1577 }, 389 - args: [ 390 - { 391 - name: 'limit', 392 - type: { 393 - kind: 'SCALAR', 394 - name: 'Int', 395 - ofType: null, 396 - }, 397 - }, 398 - { 399 - name: 'skip', 400 - type: { 401 - kind: 'SCALAR', 402 - name: 'Int', 403 - ofType: null, 404 - }, 405 - }, 406 - ], 1578 + defaultValue: null, 1579 + }, 1580 + ], 1581 + }, 1582 + { 1583 + name: 'deprecated', 1584 + description: 1585 + 'Marks an element of a GraphQL schema as no longer supported.', 1586 + locations: [ 1587 + 'FIELD_DEFINITION', 1588 + 'ARGUMENT_DEFINITION', 1589 + 'INPUT_FIELD_DEFINITION', 1590 + 'ENUM_VALUE', 1591 + ], 1592 + args: [ 1593 + { 1594 + name: 'reason', 1595 + description: 1596 + 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', 1597 + type: { 1598 + kind: 'SCALAR', 1599 + name: 'String', 1600 + ofType: null, 1601 + }, 1602 + defaultValue: '"No longer supported"', 407 1603 }, 408 1604 ], 409 - interfaces: [], 410 1605 }, 411 1606 { 412 - kind: 'SCALAR', 413 - name: 'Boolean', 1607 + name: 'specifiedBy', 1608 + description: 1609 + 'Exposes a URL that specifies the behaviour of this scalar.', 1610 + locations: ['SCALAR'], 1611 + args: [ 1612 + { 1613 + name: 'url', 1614 + description: 'The URL that specifies the behaviour of this scalar.', 1615 + type: { 1616 + kind: 'NON_NULL', 1617 + name: null, 1618 + ofType: { 1619 + kind: 'SCALAR', 1620 + name: 'String', 1621 + ofType: null, 1622 + }, 1623 + }, 1624 + defaultValue: null, 1625 + }, 1626 + ], 414 1627 }, 415 1628 ], 416 - directives: [], 417 1629 }, 418 1630 } as const;
+2
packages/example-tada/src/index.tsx
··· 38 38 console.log(fleeRate) 39 39 // Works 40 40 const po = result.data?.pokemon; 41 + 42 + // @ts-expect-error 41 43 const { pokemon: { weight: { minimum } } } = result.data || {}; 42 44 console.log(po?.name, minimum) 43 45
+2 -1
packages/example-tada/tsconfig.json
··· 6 6 "schema": "./schema.graphql", 7 7 "disableTypegen": true, 8 8 "shouldCheckForColocatedFragments": true, 9 - "trackFieldUsage": true 9 + "trackFieldUsage": true, 10 + "tadaOutputLocation": "." 10 11 } 11 12 ], 12 13 "jsx": "react-jsx",
+3 -22
packages/graphqlsp/README.md
··· 67 67 unused fragments and provide a message notifying you about them (only works with call-expressions, default: true) 68 68 - `trackFieldUsage` this only works with the client-preset, when turned on it will warn you about 69 69 unused fields within the same file. (only works with call-expressions, default: true) 70 - 71 - ### GraphQL Code Generator client-preset 72 - 73 - For folks using the `client-preset` you can ues the following config 74 - 75 - ```json 76 - { 77 - "compilerOptions": { 78 - "plugins": [ 79 - { 80 - "name": "@0no-co/graphqlsp", 81 - "schema": "./schema.graphql", 82 - "disableTypegen": true, 83 - "templateIsCallExpression": true, 84 - "shouldCheckForColocatedFragments": true, 85 - "trackFieldUsage": true, 86 - "template": "graphql" 87 - } 88 - ] 89 - } 90 - } 91 - ``` 70 + - `tadaOutputLocation` when using `gql.tada` this can be convenient as it automatically generates 71 + an `introspection.ts` file for you, just give it the directory to output to and you're done 72 + 92 73 93 74 ## Tracking unused fields 94 75
+41
packages/graphqlsp/src/graphql/getSchema.ts
··· 4 4 buildClientSchema, 5 5 getIntrospectionQuery, 6 6 IntrospectionQuery, 7 + introspectionFromSchema, 7 8 } from 'graphql'; 8 9 import fetch from 'node-fetch'; 9 10 import path from 'path'; ··· 19 20 export const loadSchema = ( 20 21 root: string, 21 22 schema: SchemaOrigin | string, 23 + tadaOutputLocation: string | undefined, 22 24 logger: Logger 23 25 ): { current: GraphQLSchema | null; version: number } => { 24 26 const ref: { current: GraphQLSchema | null; version: number } = { ··· 71 73 logger(`Got error while fetching introspection ${result}`); 72 74 } else if (result.data) { 73 75 try { 76 + if (tadaOutputLocation) { 77 + fs.promises.writeFile( 78 + path.resolve( 79 + root, 80 + '..', 81 + tadaOutputLocation, 82 + 'introspection.ts' 83 + ), 84 + `export const introspection = ${JSON.stringify( 85 + result.data, 86 + undefined, 87 + 2 88 + )} as const`, 89 + 'utf-8' 90 + ); 91 + } 92 + 74 93 ref.current = buildClientSchema( 75 94 (result as { data: IntrospectionQuery }).data 76 95 ); ··· 100 119 ref.current = isJson 101 120 ? buildClientSchema(JSON.parse(contents)) 102 121 : buildSchema(contents); 122 + 123 + if (tadaOutputLocation) { 124 + const introspection = isJson 125 + ? contents 126 + : JSON.stringify(introspectionFromSchema(ref.current), undefined, 2); 127 + fs.promises.writeFile( 128 + path.resolve(root, '..', tadaOutputLocation, 'introspection.ts'), 129 + `export const introspection = ${introspection} as const`, 130 + 'utf-8' 131 + ); 132 + } 103 133 ref.version = ref.version + 1; 104 134 }); 105 135 ··· 107 137 ? buildClientSchema(JSON.parse(contents)) 108 138 : buildSchema(contents); 109 139 ref.version = ref.version + 1; 140 + 141 + if (tadaOutputLocation) { 142 + const introspection = isJson 143 + ? contents 144 + : JSON.stringify(introspectionFromSchema(ref.current), undefined, 2); 145 + fs.promises.writeFile( 146 + path.resolve(root, '..', tadaOutputLocation, 'introspection.ts'), 147 + `export const introspection = ${introspection} as const`, 148 + 'utf-8' 149 + ); 150 + } 110 151 111 152 logger(`Got schema and initialized watcher for ${schema}`); 112 153 }
+7
packages/graphqlsp/src/index.ts
··· 5 5 import { getGraphQLQuickInfo } from './quickInfo'; 6 6 import { getGraphQLDiagnostics } from './diagnostics'; 7 7 import { templates } from './ast/templates'; 8 + import { Kind, buildClientSchema, printIntrospectionSchema } from 'graphql'; 8 9 9 10 function createBasicDecorator(info: ts.server.PluginCreateInfo) { 10 11 const proxy: ts.LanguageService = Object.create(null); ··· 27 28 shouldCheckForColocatedFragments?: boolean; 28 29 template?: string; 29 30 trackFieldUsage?: boolean; 31 + tadaOutputLocation?: string; 30 32 }; 31 33 32 34 function create(info: ts.server.PluginCreateInfo) { ··· 45 47 if (config.template) { 46 48 templates.add(config.template); 47 49 } 50 + 48 51 const proxy = createBasicDecorator(info); 49 52 50 53 const schema = loadSchema( 51 54 info.project.getProjectName(), 52 55 config.schema, 56 + // TODO: either we check here for the client having a package.json 57 + // with gql.tada and use a default file loc or we use a config 58 + // option with a location 59 + config.tadaOutputLocation, 53 60 logger 54 61 ); 55 62