Created
September 30, 2023 08:51
-
-
Save acomagu/ebe883e861a36e3e95b0180e6e7c3b19 to your computer and use it in GitHub Desktop.
Get Schema SDL from Remote GraphQL API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphql from 'graphql'; | |
const resp = await fetch(url, { method: 'POST', body: JSON.stringify({ query: graphql.getIntrospectionQuery() }), headers: { 'content-type': 'application/json' } }); | |
const introspectionResult = await resp.json(); | |
const schema = graphql.buildClientSchema(introspectionResult.data); | |
const sdl = graphql.printSchema(schema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment