Skip to content

Commit 4e53e9c

Browse files
committed
Add API schema introspection docs
I.e. how to query for a GraphQL schema from its API.
1 parent a837ea8 commit 4e53e9c

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

contrib/schema introspection.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Introspecting the Wikifactory GraphQL API schema.
2+
3+
One could send a GraphQL query to an API to obtain its complete schema:
4+
https://stackoverflow.com/a/46543255/186904
5+
6+
Here's the query:
7+
8+
```
9+
query IntrospectionQuery {
10+
__schema {
11+
queryType {
12+
name
13+
}
14+
mutationType {
15+
name
16+
}
17+
subscriptionType {
18+
name
19+
}
20+
types {
21+
...FullType
22+
}
23+
directives {
24+
name
25+
description
26+
locations
27+
args {
28+
...InputValue
29+
}
30+
}
31+
}
32+
}
33+
34+
fragment FullType on __Type {
35+
kind
36+
name
37+
description
38+
fields(includeDeprecated: true) {
39+
name
40+
description
41+
args {
42+
...InputValue
43+
}
44+
type {
45+
...TypeRef
46+
}
47+
isDeprecated
48+
deprecationReason
49+
}
50+
inputFields {
51+
...InputValue
52+
}
53+
interfaces {
54+
...TypeRef
55+
}
56+
enumValues(includeDeprecated: true) {
57+
name
58+
description
59+
isDeprecated
60+
deprecationReason
61+
}
62+
possibleTypes {
63+
...TypeRef
64+
}
65+
}
66+
67+
fragment InputValue on __InputValue {
68+
name
69+
description
70+
type {
71+
...TypeRef
72+
}
73+
defaultValue
74+
}
75+
76+
fragment TypeRef on __Type {
77+
kind
78+
name
79+
ofType {
80+
kind
81+
name
82+
ofType {
83+
kind
84+
name
85+
ofType {
86+
kind
87+
name
88+
ofType {
89+
kind
90+
name
91+
ofType {
92+
kind
93+
name
94+
ofType {
95+
kind
96+
name
97+
ofType {
98+
kind
99+
name
100+
}
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
107+
}
108+
```
109+
110+
The results are stored in `WIF_schema.json`, and converted for use with the [`sgqlc`](https://github.com/profusion/sgqlc) library into `WIF_schema.py`.

0 commit comments

Comments
 (0)