0.0.3 • Published 5 years ago

js-to-graphql-schema v0.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

js-to-graphql-schema

About

js-to-graphql-schema可以将json或javascript对象转化成graphql schema,写这个库的起因是因为要将restful接口重构为graphql接口,js-to-graphql-schema可以根据返回的数据结构自动生成类型定义.

feature

  • support any available javascript object string
  • support comment

Demo

{
 people: [
   {
     name: "xiaoli",//名字
     age: 21
   }
 ]
}

->

type Root {
  people: [People]
}
type People {
  #名字
  name: String
  age: Int
}

install

$ npm install js-to-graphql-schema

Usage

const generateGraphqlSchema=require('js-to-graphql-schema')
//available javascript object literal
const str=`
{
  people: [
    {
      name: "xiaoli",//名字
      age: 21
    }
  ]
}
`
const schema=generateGraphqlSchema(str)
console.log(schema)
0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago