Skip to content

Instantly share code, notes, and snippets.

@acomagu
Created September 30, 2023 08:51
Show Gist options
  • Save acomagu/ebe883e861a36e3e95b0180e6e7c3b19 to your computer and use it in GitHub Desktop.
Save acomagu/ebe883e861a36e3e95b0180e6e7c3b19 to your computer and use it in GitHub Desktop.
Get Schema SDL from Remote GraphQL API
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