Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

makeAugmentedSchema should work with array of typeDefs #196

Open
johnymontana opened this issue Feb 12, 2019 · 4 comments
Open

makeAugmentedSchema should work with array of typeDefs #196

johnymontana opened this issue Feb 12, 2019 · 4 comments

Comments

@johnymontana
Copy link
Contributor

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

@Stradivario
Copy link

Stradivario commented Mar 31, 2019

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

@aonamrata
Copy link

👍 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.

@anakornk
Copy link

anakornk commented Jun 1, 2020

👍 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?

@michaeldgraham
Copy link
Collaborator

#608

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants