[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Given that GraphQL schema
type User {
name: String
address: Address
}
type Address {
street: String
location: Location
}
type Location {
latitude: Float!
longitude: Float!
}
type Query {
users: [User!]
}
and this UserResolver
import { Resolver, Query, ResolveProperty } from '@nestjs/graphql';
@Resolver('User')
export class UserResolver {
@Query()
users() {
return [{ name: 'Hans' }];
}
@ResolveProperty()
address() {
return { street: 'Main Street' };
}
@Resolver('Address')
@ResolveProperty('location')
location() {
return {
latitude: 8.3,
longitude: 1.3,
};
}
}
Nest termaintes with (node:85597) UnhandledPromiseRejectionWarning: Error: Address.Address defined in resolvers, but not in schema
Instead of writing a dedicated ChildResolver I would like to resolve a property within the ParentResolver liek this:
@Resolver("Parent")
export class ParentResolver {
@Resolver("Child")
@ResolveProperty("ChildProperty")
childProperty() {}
}
https://github.com/cschroeter/nestjs-graphql-resolver/tree/master/src
Reduce the amount of resolvers needed for simple ChildProperties.
Nest version: latest
For Tooling issues:
- Node version: latest
- Platform: Mac
Others:
Also given that schema
interface Animal {
name: String!
friends: [Animal!]!
}
type Cat implements Animal {
name: String!
friends: [Animal!]!
}
type Dog implements Animal {
name: String!
friends: [Animal!]!
}
type Query {
animals: [Animal!]!
}
import { Resolver, ResolveProperty, Parent, Query } from '@nestjs/graphql';
@Resolver('Animal')
export class AnimalResolver {
@Query()
animals() {
return [{ name: 'Susi' }];
}
@ResolveProperty()
async friends(@Parent() animal) {
return [{ name: 'Strolch' }];
}
@ResolveProperty()
__resolveType(animal): string {
// it is always a cat 馃榿
return 'Cat';
}
}
Fails with "message": "Cannot return null for non-nullable field Cat.friends."
This will fail also :(
So, this was closed, but did you find any solution or got to any conclusion? I am trying to implement with some typings a cursor based pagination under the same schema but got to face the same problem.
type Query {
categories(): CategoryConnection!
}
type CategoryConnection {
totalCount: Int!
edges: [CategoryEdge!]!
}
type CategoryEdge {
cursor: String!
node: CategoryType!
}
type CategoryType {
id: ID!
name: String!
}
What was the final result to your problem?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
So, this was closed, but did you find any solution or got to any conclusion? I am trying to implement with some typings a cursor based pagination under the same schema but got to face the same problem.
What was the final result to your problem?