Skip to content

Instantly share code, notes, and snippets.

@dualfade
Created December 9, 2021 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dualfade/28694086d2b2800598a96035bac7e9ba to your computer and use it in GitHub Desktop.
Save dualfade/28694086d2b2800598a96035bac7e9ba to your computer and use it in GitHub Desktop.
// ref --
// https://bit.ly/3rRPy2m
// https://github.com/graphql/graphql.github.io/tree/source/src/content/graphql-js
const path = require("path");
const fs = require("fs");
// const fetch = require("node-fetch");
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const {
getIntrospectionQuery,
printSchema,
buildClientSchema
} = require("graphql");
async function main() {
const introspectionQuery = getIntrospectionQuery();
const response = await fetch(
"https://host.target.com/graphql",
{
method: "POST",
headers: {
"Cookie": "add; j00++; cookies; f00++",
"Content-Type": "application/json"
},
body: JSON.stringify({ query: introspectionQuery })
}
);
const { data } = await response.json();
const schema = buildClientSchema(data);
const outputFile = path.join(__dirname, "./result.gql");
await fs.promises.writeFile(outputFile, printSchema(schema));
}
// run main --
console.log("[+] running --")
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment