You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modifying a field on a type surprisingly modifies the generated "source type", on the object, even if the signature is the same. This causes typing errors in the parent field resolver.
import{interfaceType,objectType}from'nexus';exportconstNode=interfaceType({name: 'Node',definition(t){t.nonNull.id('id',{resolve(){return'<example>';},});},});exportconstChildObjectType=objectType({name: 'ChildObjectType',definition(t){t.implements(Node);// Without this, there are no typing errors,// and the parent only needs to resolve "firstName" & "lastName".// But when added, it complains about the parent not passing "id" as well.t.modify('id',{resolve(){return'<modified-example>';},});t.nonNull.string('firstName');t.nonNull.string('lastName');t.nonNull.string('fullName',{resolve(source){return`${source.firstName}${source.lastName}`;},});},});exportconstParentObjectType=objectType({name: 'ParentObjectType',definition(t){t.field('child',{type: ChildObjectType,resolve(){// <-- This is where it throws a type errorreturn{firstName: 'child',lastName: 'child',};},});},});
Generated typescript output:
// Without modifying "id"exportinterfaceNexusGenObjects{ChildObjectType: {firstName: string;lastName: string;}}// After modifying "id"exportinterfaceNexusGenObjects{ChildObjectType: {id: string;firstName: string;lastName: string;}}
The text was updated successfully, but these errors were encountered:
Modifying a field on a type surprisingly modifies the generated "source type", on the object, even if the signature is the same. This causes typing errors in the parent field resolver.
Generated typescript output:
The text was updated successfully, but these errors were encountered: