Answer the question
In order to leave comments, you need to log in
Is there a Node.js API to generate a GraphQL schema file on the fly?
I am writing an application with Node.js backend and GraphQL API.
I use Nodemon to restart the server on code changes.
I describe the GraphQL schema in a standard programmatic way of the form:
const UserQuery = {
type: GraphQLUser,
args: {
id: { type: GraphQLString }
},
resolve: async (root, { id }, context) => {
if (id) return await User.findById(fromGlobalId(id).id)
return context.request.user
}
}
Answer the question
In order to leave comments, you need to log in
can be generated programmatically at startup if you have schema in memory:
https://blog.apollographql.com/three-ways-to-repre...
See section "Converting between all of the different types"
You can also save schema.graphql and schema.json.
You can make a watcher in the IDE so that when you change the necessary files, it launches a script that will load your scheme and export it to a file.
And other perversions to your taste.
Another question - why do you need it at all, it's easier to write everything in * .graphql files or in ts with the gql tag and import them directly, and use them to work with all sorts of tools / plugins and other things.
for this, blue-green deployment is usually used. a new project instance is launched and then traffic is switched to it. And you are trying to solve this problem as a typical developer on your own
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question