How can I merge a schema after infer it from the driver?

83 views Asked by At

I'm using inferSchema for generate GraphQL type definitions directly from the neo4j database, like this:

const inferAugmentedSchema = driver => {
    return inferSchema(driver).then(result => {
        return makeAugmentedSchema({
            typeDefs: result.typeDefs,
            config: {
                mutation: false
            }
        });
    })
};

Now I need to merge the schema above with another, so I can extend a type, but everytime I try raises this error:

Initializing your Neo4j Schema
This may take a few moments depending on the size of your DB pathToProject\node_modules\graphql\validation\validate.js:124
throw new Error(errors.map(function (error) { ^ Error: Cannot extend type "Municipio" because it is not defined.

Here is the full code of how I'm trying to merge it:

    const driver = neo4j.driver(
    process.env.URL,
    neo4j.auth.basic(process.env.NEO4J_USER, process.env.NEO4J_PWD)
);

 const inferAugmentedSchema = driver => {
    return inferSchema(driver).then(result => {
        return makeAugmentedSchema({
            typeDefs: result.typeDefs,
            config: {
                mutation: false
            }
        });
    })
};

const types = [
    inferAugmentedSchema,
    municipioExtended,
];

const mergedSchema = mergeSchemas({
    schemas: [typeDefs, municipioExtended]
});

const server = new ApolloServer({
    mergedSchema,
    context: { driver }
});

server.listen().then(({url}) => {
    console.log(`server ready at ${url}`)
});
0

There are 0 answers