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
import{GraphQLObjectType}from'graphql';import{ProjectFields}from'./project.fields';import{ProjectInterfaceType}from'./project-interface.type';exportconstProjectType: GraphQLObjectType=newGraphQLObjectType({name: 'ProjectType',interfaces: [ProjectInterfaceType],description: 'GraphQL Type for Project',fields: ProjectFields});
import{GraphQLInterfaceType}from'graphql';import{ProjectFields,ProjectPrivateFields}from'./project.fields';import{ProjectType}from'./project.type';import{ProjectPrivateType}from'./project-private.type';exportconstProjectInterfaceType: GraphQLInterfaceType=newGraphQLInterfaceType({name: 'ProjectInterfaceType',fields: ProjectFields,resolveType: (data,context)=>{returnProjectType;// <-- I need to conditionally return either ProjectType or ProjectPrivateType}});
Whenever I change the return type from the resolveType from ProjectType to ProjectPrivateType I get the following error:
TypeError: Cannot read property 'name' of undefined
at ...\node_modules\graphql\type\schema.js:136:52
at Array.forEach (<anonymous>)
at ...\node_modules\graphql\type\schema.js:135:30
at Array.forEach (<anonymous>)
at new GraphQLSchema (...\node_modules\graphql\type\schema.js:132:32)
...
Update
I found out that it seems like some circular reference not being resolved. If I simply return the name of the type as a string, it works:
import{GraphQLInterfaceType}from'graphql';import{ProjectFields,ProjectPrivateFields}from'./project.fields';import{ProjectType}from'./project.type';import{ProjectPrivateType}from'./project-private.type';exportconstProjectInterfaceType: GraphQLInterfaceType=newGraphQLInterfaceType({name: 'ProjectInterfaceType',fields: ProjectFields,resolveType: (data,context)=>{return'ProjectPrivateType';// <-- this actually works}});
The text was updated successfully, but these errors were encountered:
@IvanGoncharov That's a shame! Your solution for the arrow function works, so thanks a lot! I've spent hours trying refactored version of the codebase, didn't come up with this.
I have two types that implement an interface:
1. project.type.ts
2. project-private.type.ts
project-interface.type.ts
I also have the types declared in my schema:
Whenever I change the return type from the
resolveType
fromProjectType
toProjectPrivateType
I get the following error:Update
I found out that it seems like some circular reference not being resolved. If I simply return the name of the type as a string, it works:
The text was updated successfully, but these errors were encountered: