graphql2props

0.0.3 • Public • Published

graphql2props

Generate react proptypes from graphql schema

installation

npm i graphql2props

usage

in code

import graphql2props from 'graphql2props'
import { readFileSync } from 'fs'

const code = graphql2props(readFileSync('schema.graphql').toString())

in cli

npx graphql2props schema.graphql > props.js

You might have to tune the output a bit (custom scalars aren't supported, for example.) but you can use the props like this:

import React from 'react'
import { Type1, Type2 } from './props'

const MyThing = ({ propA, propB }) => (<div>COOL</div>)

MyThing.propTypes = {
  propA: Type1,
  propB: Type2
}

Package Sidebar

Install

npm i graphql2props

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

229 kB

Total Files

8

Last publish

Collaborators

  • konsumer