-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start rewrite the full schema generation code, last step
- Loading branch information
1 parent
323eb9f
commit 0b5e84d
Showing
14 changed files
with
2,432 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Finalize the graphql schema creation | ||
*/ | ||
|
||
import { makeExecutableSchema } from "apollo-server"; | ||
import { mergeSchemas } from "graphql-tools"; | ||
import { REPL_MODE_SLOPPY } from "repl"; | ||
import { VulcanGraphqlModel } from "../typings"; | ||
import { generateGraqhqlSchema } from "./graphql"; | ||
import generateTypeDefs from "./typedefs"; | ||
|
||
// TODO: we probably don't need this anymore | ||
// INstead, compute the schema for all models in graphql.ts | ||
const initGraphQL = (models: Array<VulcanGraphqlModel>): void => { | ||
// TODO: merge all models | ||
const { resolvers, queries, mutations, typeDefs } = model | ||
const typeDefs = generateTypeDefs({ | ||
additionalTypeDefs: GraphQLSchema.getAdditionalSchemas(), | ||
modelTypeDefs: GraphQLSchema.getCollectionsSchemas(), | ||
queries: GraphQLSchema.queries, | ||
mutations: GraphQLSchema.mutations, | ||
}); | ||
|
||
const executableSchema = makeExecutableSchema({ | ||
typeDefs, | ||
resolvers: GraphQLSchema.resolvers, | ||
schemaDirectives: GraphQLSchema.directives, | ||
}); | ||
// only call mergeSchemas if we actually have stitchedSchemas | ||
// const mergedSchema = | ||
// GraphQLSchema.stitchedSchemas.length > 0 | ||
// ? mergeSchemas({ | ||
// schemas: [executableSchema, ...GraphQLSchema.stitchedSchemas], | ||
// }) | ||
// : executableSchema; | ||
// | ||
return executableSchema, | ||
}; | ||
|
||
export default initGraphQL; |
Oops, something went wrong.