graphql-nexus / nexus

Code-First, Type-Safe, GraphQL Schema Construction
https://nexusjs.org
MIT License
3.4k stars 275 forks source link

'isTypeOf' does not exist in type 'NexusObjectTypeConfig #1134

Closed arvi closed 2 years ago

arvi commented 2 years ago
Object literal may only specify known properties, and 'isTypeOf' does not exist in type 'NexusObjectTypeConfig

Hello,

I tried to follow the guide here but ended up with that issue above.

schema.ts

export const schema = makeSchema({
    types: allTypes,
    features: {
        abstractTypeStrategies: {
            isTypeOf: true,
        },
    },
...

types

export const Clothing = unionType({
    name: 'Clothing',
    definition(t) {
        t.members('Summer', 'Winter',  'Spring');
    },
});

export const Summer = objectType({
    name: 'Summer',
    description: 'Summer clothing description here',
    isTypeOf(data) { // <--  Object literal may only specify known properties, and 'isTypeOf' does not exist in type 'NexusObjectTypeConfig
        return Boolean(data.testAttr1);
    },
    definition(t) {
    ...
    },
 });

export const Winter = objectType({
    name: 'Winter',
    description: 'Winter clothing description here',
    isTypeOf(data) {
        return Boolean(data.testAttr2);
    },
    definition(t) {
    ...
    },
 });

export const Spring = objectType({
    name: 'Spring',
    description: 'Spring clothing description here',
    isTypeOf(data) {
        return Boolean(data.testAttr3);
    },
    definition(t) {
    ...
    },
 });
arvi commented 2 years ago

Closing this issue. Probably a delay in editor of the changes made to schema. Closed the file, opened it again and the TS error was gone. 😆😂