GraphQL not showing schema and documentation NestJS

GraphQL not showing schema and documentation NestJS


0

I’m working on GraphQL using NestJS and I’ve not created models separately so, in short, I combine them but my GraphQL playground is not showing schemas and documentation of my queries and mutations.

GraphQL Config

{
  driver: ApolloDriver,
  autoSchemaFile: true,
  path: SERVER_PREFIX_URL,
  debug: true,
  playground: true,
  introspection: true,
  plugins: [
    ApolloServerPluginQueryComplexity({
      estimators: [directiveEstimator(), simpleEstimator()],
      maximumComplexity: config.GQL_QUERY_COMPLEXITY,
    }),
  ],
  context: ({ req, res }) => ({ req, res }),
}

user.entity.ts

@Entity('users')
@ObjectType('User')
export class User extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'first_name' })
  @Field(() => String)
  firstName: string;

  @Column({ name: 'last_name' })
  @Field(() => String)
  lastName: string;

  @Column()
  @Field(() => String)
  mobile: string;

  @OneToMany(() => Address, (address) => address.user, { cascade: true })
  @Field(() => [Address])
  addresses?: Promise<Address[]>;
}

user.resolver.ts

@Resolver((of) => User)
export class UserResolver {
  constructor(private userService: UserService) {}

  @Query((returns) => User)
  user(@Args({ name: 'id' }) id: string) {
    return this.userService.getUserById(id);
  }
}

versions

{
    "@nestjs/graphql": "^10.1.1",
    "graphql": "^16.6.0",
    "graphql-depth-limit": "^1.1.0",
    "graphql-query-complexity": "^0.12.0",
    "graphql-tools": "^8.3.6",
}

When I click on schema or documentation in Playground so it always shows the loading.

Share
Improve this question

1 Answer
1

Reset to default


0

This behavior is connected to your .env file. When you set the NODE_ENV variable to ‘production’, certain features of the GraphQL playground are affected. In this case, the playground gets disabled.

Share
Improve this answer

New contributor

marat sahakyan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



Leave a Reply

Your email address will not be published. Required fields are marked *