Comments (5)
If it's of any help, here's a script I'm currently using (I think I just copied it from Relay):
const fetch = require('node-fetch')
const fs = require('fs')
const {
buildClientSchema,
introspectionQuery,
printSchema,
} = require('graphql/utilities')
const path = require('path')
const schemaPath = path.join(__dirname, '..', 'schema')
const SERVER = 'http://localhost:3000/graphql'
fetch(`${SERVER}`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({'query': introspectionQuery}),
}).then(res => res.json()).then(schemaJSON => {
fs.writeFileSync(
`${schemaPath}.json`,
JSON.stringify(schemaJSON, null, 2)
)
// Save user readable type system shorthand of schema
const graphQLSchema = buildClientSchema(schemaJSON.data)
fs.writeFileSync(
`${schemaPath}.graphql`,
printSchema(graphQLSchema)
)
})
And then run from npm/yarn:
"update-schema": "babel-node ./scripts/updateSchema.js && gql2flow -o schema.flow.js schema.json"
from gql2flow.
I really like this idea, I'll see what I can do!
from gql2flow.
Added this in the latest version (0.4.x), please do try it out. No support for auth headers right now but can add if there is need.
from gql2flow.
@capaj try using apollo-codegen for this, you can combine it with this package and you'll get what you want :)
from gql2flow.
Any chance of this getting added to the core?
from gql2flow.
Related Issues (20)
- question-wouldn't it make more sense to place the "?" on a property key? HOT 7
- whitelist types additional to ignore types HOT 1
- bug on GraphQLEnumType
- Provide a non global npm package as well HOT 1
- Whats the reason for `__typename`? HOT 2
- Activate Travis for this repository
- Fix the tests HOT 1
- Input types are empty
- Option to generate types using `export` rather than `declare`. HOT 1
- Provide support for custom scalars, e.g. `Date`.
- Latest release (0.4.4) is broken HOT 1
- Feature request: upgrade to latest graphql standards HOT 1
- Cannot find module 'graphql/utilities' HOT 1
- Optional fields on Input types are only set as maybe and not optional HOT 1
- Make output deterministic (the same each time it is run)
- gql2ts HOT 3
- is this repo still maintained? HOT 2
- GraphQL SDL and FlowType descrepencies HOT 2
- fields with default values should not be marked as optional HOT 1
- Generate correct types for queries and mutations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gql2flow.