File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "__schema" : {
3+ "types" : [
4+ {
5+ "kind" : " INTERFACE" ,
6+ "name" : " Node" ,
7+ "possibleTypes" : [
8+ { "name" : " Frame" },
9+ { "name" : " Text" },
10+ { "name" : " Rectangle" },
11+ { "name" : " Vector" }
12+ ]
13+ },
14+ {
15+ "kind" : " UNION" ,
16+ "name" : " Children" ,
17+ "possibleTypes" : [
18+ { "name" : " Text" },
19+ { "name" : " Rectangle" },
20+ { "name" : " Vector" },
21+ { "name" : " Frame" }
22+ ]
23+ }
24+ ]
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ {
2+ "env" : {
3+ "node" : true
4+ },
5+ "rules" : {
6+ "no-console" : " off"
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ const fetch = require ( "node-fetch" )
2+ const fs = require ( "fs" )
3+
4+ const { API_HOST } = process . env
5+
6+ fetch ( `${ API_HOST } /graphql` , {
7+ method : "POST" ,
8+ headers : { "Content-Type" : "application/json" } ,
9+ body : JSON . stringify ( {
10+ variables : { } ,
11+ query : `
12+ {
13+ __schema {
14+ types {
15+ kind
16+ name
17+ possibleTypes {
18+ name
19+ }
20+ }
21+ }
22+ }
23+ `
24+ } )
25+ } )
26+ . then ( result => result . json ( ) )
27+ . then ( result => {
28+ // here we're filtering out any type information unrelated to unions or interfaces
29+ const filteredData = result . data . __schema . types . filter (
30+ type => type . possibleTypes !== null
31+ )
32+ result . data . __schema . types = filteredData
33+ fs . writeFile ( "./fragmentTypes.json" , JSON . stringify ( result . data ) , err => {
34+ if ( err ) {
35+ console . error ( "Error writing fragmentTypes file" , err )
36+ } else {
37+ console . log ( "Fragment types successfully extracted!" )
38+ }
39+ } )
40+ } )
41+ . catch ( error => {
42+ console . error ( `Could not fetch GQL types information.
43+
44+ ${ error }
45+ ` )
46+ } )
Original file line number Diff line number Diff line change 1+ query IntrospectionQuery {
2+ __schema {
3+ queryType { name }
4+ mutationType { name }
5+ types {
6+ ... FullType
7+ }
8+ directives {
9+ name
10+ description
11+ locations
12+ args {
13+ ... InputValue
14+ }
15+ }
16+ }
17+ }
18+ fragment FullType on __Type {
19+ kind
20+ name
21+ description
22+ fields (includeDeprecated : true ) {
23+ name
24+ description
25+ args {
26+ ... InputValue
27+ }
28+ type {
29+ ... TypeRef
30+ }
31+ isDeprecated
32+ deprecationReason
33+ }
34+ inputFields {
35+ ... InputValue
36+ }
37+ interfaces {
38+ ... TypeRef
39+ }
40+ enumValues (includeDeprecated : true ) {
41+ name
42+ description
43+ isDeprecated
44+ deprecationReason
45+ }
46+ possibleTypes {
47+ ... TypeRef
48+ }
49+ }
50+ fragment InputValue on __InputValue {
51+ name
52+ description
53+ type { ... TypeRef }
54+ defaultValue
55+ }
56+ fragment TypeRef on __Type {
57+ kind
58+ name
59+ ofType {
60+ kind
61+ name
62+ ofType {
63+ kind
64+ name
65+ ofType {
66+ kind
67+ name
68+ ofType {
69+ kind
70+ name
71+ ofType {
72+ kind
73+ name
74+ ofType {
75+ kind
76+ name
77+ ofType {
78+ kind
79+ name
80+ }
81+ }
82+ }
83+ }
84+ }
85+ }
86+ }
87+ }
You can’t perform that action at this time.
0 commit comments