Skip to content

mix the code first and the schema first approach #937

@renehauck

Description

@renehauck

I'm submitting a...


[ ] Regression 
[? ] Bug report
[? ] Feature request
[X ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I have a plugin that automatically generates a graphql schema from my database and stores it in schema.graphql in the root directory.
Now this is the schema first approach. But I would like to add more resolvers that are not included in the generated schema.

Expected behavior

So I would like to mix schema first approach and code first approach.

Minimal reproduction of the problem with instructions

I have the automatically generated schema.graphql file and create an additional resolver HelloResolver

@Resolver("Hello")
export class HelloResolver {
  @Query(()=>String)
  hello() {
    return "hello";
  }
}

and import the module

GraphQLModule.forRoot({
      typePaths: ["./schema.graphql","./schema2.graphql"],
      autoSchemaFile:"./schema2.graphql"
    })

but now when I start the server I get the error message
UnhandledPromiseRejectionWarning: Error: "Mutation" defined in resolvers, but not in schema
The file schema2.graphql is created without any problems but including schema.graphql and schema2.graphql does not seem to work.

What is the motivation / use case for changing the behavior?

It should be possible to mix the code first and the schema first approach.

Thank you!

Environment


Nest version: 7.1.2

 
For Tooling issues:
- Node version: v10.19.0  
- Platform:  Linux

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions