js-to-graphql-schema
v0.0.3
Published
`js-to-graphql-schema`可以将json或javascript对象转化成graphql schema,写这个库的起因是因为要将restful接口重构为graphql接口,`js-to-graphql-schema`可以根据返回的数据结构自动生成类型定义. ## feature - support any available javascript object string - support comment
Downloads
4
Readme
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)