Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Save type system shorthand of schema to schema.graphql on npm run update-schema #10

Merged

Conversation

albertstill
Copy link
Contributor

I think it would be a really nice form of documentation to have a .graphql file in a Relay repo of the type system shorthand(aka GraphQL Schema language) representation of the schema. Useful to reference while developing to.

I have put the code for it in the update-schema script and it uses the graphql-js printSchema utility. There could be a better way of doing this.

To be run on `npm run update-schema`
@steveluscher
Copy link
Contributor

What do you think about:

  1. Putting this feature behind a CLI flag. Maybe…

    ./updateSchema.js --print
    
  2. Adding schema.graphql to the .gitignore file. It's a build artifact, so maybe we shouldn't check it in?

@albertstill
Copy link
Contributor Author

Ok cool. Looked into the argument stuff it's a bit messy. Our npm script is calling babel-node ./scripts/updateSchema.js underneath. Therefore as documented on npm we would have to call it with -- prepended e.g npm run update-schema -- --print-schema (--print is a reserved word) and then call process.argv.indexOf('--print-schema') > -1 in the script etc. I reckon we just add it to .gitignore and have it at the same level as schema.js as you said. Just done another commit let me know what you think.

Also side note. Is schema.json also a build artefact and therefore should also be in the .gitignore? I know babel-relay-plugin relies on it so could we have the start script call npm run update-schema && babel-node ./server.js so it creates or updates the schema.json before it starts.

steveluscher added a commit that referenced this pull request Aug 20, 2015
Save type system shorthand of schema to schema.graphql on `npm run update-schema`
@steveluscher steveluscher merged commit b2a1e0e into facebookarchive:master Aug 20, 2015
@steveluscher
Copy link
Contributor

Eventually, I'm going to make it so that schema.json never hits the filesystem (#13).

Thanks for this PR! I'm sure that others will find it helpful to have the types documented. If you feel like applying a similar change to the three examples in facebook/relay, I'd be happy to accept that one too!

@albertstill
Copy link
Contributor Author

@steveluscher done facebook/relay#160

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants