| 139 | } |
| 140 | |
| 141 | export async function getClientSchema( |
| 142 | introspectionUrl: string, |
| 143 | headers: Headers, |
| 144 | ) { |
| 145 | headers.set(HTTPHeaders.contentType, 'application/json') |
| 146 | const resp = await fetch(introspectionUrl, { |
| 147 | body: JSON.stringify({ |
| 148 | operationName: 'IntrospectionQuery', |
| 149 | query: introspectionQuery, |
| 150 | }), |
| 151 | headers, |
| 152 | method: 'POST', |
| 153 | }) |
| 154 | const { data } = await resp.json() |
| 155 | if (data && !data.errors) { |
| 156 | return buildClientSchema(data) |
| 157 | } |
| 158 | |
| 159 | return null |
| 160 | } |
| 161 | |
| 162 | // https://github.com/graphql/graphql-js/blob/dd0297302800347a20a192624ba6373ee86836a3/src/utilities/introspectionQuery.js#L14 |
| 163 | export const introspectionQuery = ` |