Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Serverless integration with nestjs and graphql throws error - Cannot determine a GraphQL output type for the "id". #1522

Open
aditijain-2 opened this issue Feb 24, 2022 · 2 comments

Comments

@aditijain-2
Copy link

Setup:
NestJs [8.1.6]
TypeOrm [^0.2.41]
Nestjs-Query [^0.30.0]
PostgreSQL

I am trying to achieve serverless integration in our application by referring - Nestjs serverless docs

If I start the lambda function locally, using commands -

npm run build 
npx serverless offline 

The GraphQL playground loads but crashes immediately.
It throws an error - Error: Cannot determine a GraphQL output type for the "id". Make sure your class is decorated with an appropriate decorator.
However, when I am running the application without serverless, it works.

I have added @ObjectType() decorator to the class as well.

DTO class -

@ObjectType('Section')
@QueryOptions({
  pagingStrategy: PagingStrategies.OFFSET,
  enableTotalCount: true,
})
export class SectionDTO {
  @Field(() => ID)
  id!: string;

  @FilterableField()
  name!: string;

  @FilterableField(() => GraphQLISODateTime)
  created!: Date;

  @FilterableField(() => GraphQLISODateTime)
  updated!: Date;
}

Entity Class -

import {
  BaseEntity,
  Column,
  CreateDateColumn,
  Entity,
  OneToMany,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Field, ID, ObjectType } from '@nestjs/graphql';

@Entity('section')
@ObjectType()
export class SectionEntity extends BaseEntity {
  @Field(() => ID)
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column()
  name!: string;

  @CreateDateColumn()
  created!: Date;

  @UpdateDateColumn()
  updated!: Date;
}

How can I resolve this issue?

@pratiksyngenta
Copy link

Facing the similar problem

@dan-klasson
Copy link

I'd try using @IDField instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants