Are there any tools to dynamically generate graphQl schema string?

北战南征 提交于 2019-12-03 16:47:01

The json-graphql-server project does that: Take a data JSON as input, infer types and fields from the data, write a schema containing types, queries and mutations, and start a GraphQL server schema based on that.

https://github.com/marmelab/json-graphql-server

I know of another tool that does just the JSON to schema part, but it does not generate queries or mutations:

https://github.com/aweary/json-to-graphql

It depends on how does your JSON files look like. For me I had a similar case - a kind of complex json definition file - and I built my own json to graphql-js converter here

  • After building your server you can generate the schema string in .graphql file using this package gql-tools, using this command - after launching the server - :-

    gqlschema http://localhost:3000/graphql -t

  • Use the schema string along with graphql-server-express from apollo and link it with resolvers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!