#How to get error feedback when the GraphQL mutation definition is wrong within the resolver?

3 messages · Page 1 of 1 (latest)

split fog
#

We require a code-first GraphQL approach for our application.

When creating a mutation with an incorrect @Args parameter (e.g., the wrong type), neither TypeScript nor the GraphQL plugin reports an error. The only indication of an issue is that the NestJS application fails to start when an entire object is passed as input. Is there a way to identify the problem, such as enabling additional logging?

Here’s the problematic mutation:

@Mutation(() => DummyModel)
async createDummy(
@Args('dummyInput') dummyInput: DummyModel,
): Promise<DummyModel> {
return Promise.resolve(dummyInput);
}

Changing it to the following works:

@Mutation(() => DummyModel)
async createDummy(
@Args({ name: 'postId', type: () => String }) postId: string,
): Promise<DummyModel> {
return Promise.resolve({ id: postId });
}