Following the getting started example from the docs almost exactly:

I am unable to reference the Node type in my account type.

Gives me the tslint error of
Argument of type 'NexusObjectTypeDef<"Node">' is not assignable to parameter of type 'NexusInterfaceTypeDef
'.
Property 'config' is protected but type 'NexusObjectTypeDef' is not a class derived from 'NexusInterfaceTypeDef '.ts(2345)
And a console error of
Using ts-node version 8.0.2, typescript version 3.3.3
Error: Expected [object Object] to be an interfaceType, saw GraphQLObjectType
at SchemaBuilder.getInterface (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/nexus/dist/builder.js:445:19)
at /Users/jakelowen/code/tmp_code/nexus_test/node_modules/nexus/dist/builder.js:169:89
at Array.map ()
at interfaces (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/nexus/dist/builder.js:169:57)
at resolveThunk (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/graphql/type/definition.js:374:40)
at defineInterfaces (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/graphql/type/definition.js:522:20)
at GraphQLObjectType.getInterfaces (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/graphql/type/definition.js:503:31)
at typeMapReducer (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/graphql/type/schema.js:259:23)
at Array.reduce ()
at new GraphQLSchema (/Users/jakelowen/code/tmp_code/nexus_test/node_modules/graphql/type/schema.js:108:28)
[ERROR] 21:47:25 Error: Expected [object Object] to be an interfaceType, saw GraphQLObjectType
I can get everything to work just fine if I do not attempt to implement the Node type and instead just specify the 'id' field manually.
Any idea why I am not able to implement Node as illustrated in the docs?
Here are my package versions:
"graphql": "^14.1.1",
"graphql-yoga": "^1.17.4",
"knex": "^0.16.3",
"lodash": "^4.17.11",
"nexus": "^0.9.9",
"pg": "^7.8.0"
Thank you. Seems like a very promising project!
Got it working if I swap Node from objectType to interfaceType. Also had to provide a t.resolveType(() => null); to it's definition.
resulting in:
export const Node = interfaceType({
name: "Node",
definition(t) {
t.id("id", { description: "Unique identifier for the resource" });
t.resolveType(() => null);
}
});
Perhaps the example code on https://nexus.js.org/docs/getting-started needs to be updated?
Thanks for the report! Yes the docs were indeed wrong here, pushed a fix that should update them shortly!