neo4j-graphql-js
neo4j-graphql-js copied to clipboard
makeAugmentedSchema should work with array of typeDefs
Passing an array of type definitions (instead of a single SDL string) is supported by graphql-tool's makeExecutableSchema and should also be supported by makeAugmentedSchema.
For example:
const typeDefs = [`type Person {name: String}`, `type Book {title: String}`]
const schema = makeAugmentedSchema({typeDefs})
Currently this gets hung up in extractTypeMapFromTypeDefs
You can do:
Merge schemas
import * as neo4jgql from "neo4j-graphql-js";
import { mergeSchemas } from "graphql-tools";
import { GraphQLSchema, GraphQLObjectType, printSchema } from "graphql";
const typeDefs = [`type Person {name: String}`, `type Book {title: String}`];
const augmentedSchema = neo4jgql.makeAugmentedSchema({
typeDefs: printSchema(
mergeSchemas({
schemas: typeDefs
})
)
});
Real world example https://github.com/rxdi/neo4j/blob/master/src/services/util.service.ts#L51
:+1: Thanks @Stradivario This works for me after updating graphql-tools version 5.0.0-rc.0 (because of https://github.com/apollographql/graphql-tools/issues/815)
Btw, do you know how I can use this to merge schemas with @cypher and regular with resolvers? All the combinations of makeAugmentedSchema and makeExecutableSchema are not working.
👍 Thanks @Stradivario This works for me after updating graphql-tools version 5.0.0-rc.0 (because of ardatan/graphql-tools#815)
Btw, do you know how I can use this to merge schemas with
@cypherand regular with resolvers? All the combinations ofmakeAugmentedSchemaandmakeExecutableSchemaare not working.
mergeSchemas function is removing the directives. My current workaround is to concatenate typeDef strings. Are there any better workarounds? Is there a way to fetch the relation / cypher directives so that we could add it to schemaDirectives while merging?
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608