neo4j-graphql-js icon indicating copy to clipboard operation
neo4j-graphql-js copied to clipboard

makeAugmentedSchema should work with array of typeDefs

Open johnymontana opened this issue 6 years ago • 4 comments

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

johnymontana avatar Feb 12 '19 19:02 johnymontana

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

Stradivario avatar Mar 31 '19 01:03 Stradivario

:+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.

aonamrata avatar Apr 09 '19 08:04 aonamrata

👍 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 @cypher and regular with resolvers? All the combinations of makeAugmentedSchema and makeExecutableSchema are 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?

anakornk avatar Jun 01 '20 17:06 anakornk

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608

michaeldgraham avatar May 02 '21 04:05 michaeldgraham