Zendro-dev / graphql-server

Skeleton NodeJS project for a graphQL server.
GNU General Public License v3.0
0 stars 1 forks source link

Build a simple './schemas/index.html' to enable import of a valid instance of the GraphQL schema #12

Closed asishallab closed 5 years ago

asishallab commented 5 years ago

It would be very useful to be able to get the GraphQL schema as a simple object upon a require call.

See this comment on how to do that.

var {
   buildSchema
} = require('graphql');
var mergeSchema = require('./utils/merge-schemas');
// You might have to modify __dirname depending on where your script is located:
var merged_schema = mergeSchema(path.join(__dirname, './schemas'));

module.exports.schema = buildSchema(merged_schema);

Please write an index.js in the directory schemas that automatically exports the schema after merging as pointed out in the above comment.

Expected work time: 1h

YKolokoltsev commented 5 years ago

A corresponding file is ./utils/graphql_schema.js, it is generic so that './schemas/index.html' seems to be an error.

In there is also defined a utility function that permits to find a model field by it's annotation placed within description, like @original-field.