11 changed files with 1392 additions and 1526 deletions
@ -1,39 +0,0 @@ |
|||||||
|
|
||||||
const fetch = require('node-fetch'); |
|
||||||
const fs = require('fs'); |
|
||||||
|
|
||||||
fetch(`http://localhost:4000/graphql`, { |
|
||||||
method: 'POST', |
|
||||||
headers: { 'Content-Type': 'application/json' }, |
|
||||||
body: JSON.stringify({ |
|
||||||
variables: {}, |
|
||||||
query: ` |
|
||||||
{ |
|
||||||
__schema { |
|
||||||
types { |
|
||||||
kind |
|
||||||
name |
|
||||||
possibleTypes { |
|
||||||
name |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
`,
|
|
||||||
}), |
|
||||||
}) |
|
||||||
.then(result => result.json()) |
|
||||||
.then(result => { |
|
||||||
// here we're filtering out any type information unrelated to unions or interfaces
|
|
||||||
const filteredData = result.data.__schema.types.filter( |
|
||||||
type => type.possibleTypes !== null, |
|
||||||
); |
|
||||||
result.data.__schema.types = filteredData; |
|
||||||
fs.writeFileSync('./src/fragmentTypes.json', JSON.stringify(result.data), err => { |
|
||||||
if (err) { |
|
||||||
console.error('Error writing fragmentTypes file', err); |
|
||||||
} else { |
|
||||||
console.log('Fragment types successfully extracted!'); |
|
||||||
} |
|
||||||
}); |
|
||||||
}); |
|
||||||
@ -1 +0,0 @@ |
|||||||
{"__schema":{"types":[{"kind":"INTERFACE","name":"Vector","possibleTypes":[{"name":"NumberVector"},{"name":"SwitchVector"},{"name":"TextVector"},{"name":"LightVector"}]}]}} |
|
||||||
Loading…
Reference in new issue