Created
June 27, 2023 13:19
-
-
Save ConorCorp/b5db60799ec6dac42cf32dc610998434 to your computer and use it in GitHub Desktop.
Load a schema with `@graphql-tools/url-loader` from a url, into a file.
This file contains 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 { loadSchema } from '@graphql-tools/load'; | |
import { UrlLoader } from '@graphql-tools/url-loader'; | |
import { writeFile } from 'fs'; | |
import { printSchema } from 'graphql'; | |
/* | |
* Script that loads cms's graphql schema from localhost instance. | |
* | |
* See docs here: https://the-guild.dev/graphql/tools/docs/schema-loading | |
*/ | |
async function main() { | |
const schema = await loadSchema('http://localhost:1337/graphql', { | |
loaders: [new UrlLoader()], | |
}); | |
writeFile('./__generated__/schema.graphql', printSchema(schema), (err) => { | |
if (err) { | |
console.error(err); | |
} | |
}); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment