Aller au contenu

Queries

Queries allow you to retrieve data from your GraphQL API.

The CRUD resolver automatically exposes two query endpoints. The endpoint names will be derived from the name provided to @ObjectType or the class name.

The following examples are based on a ProductDTO:

import { EnhancedField, IDField } from '@lib/type-graphql-query';
import { ObjectType, ID, GraphQLISODateTime, Field } from '@lib/type-graphql';
@ObjectType('Product')
export class ProductDTO {
@IDField(() => ID)
id!: string;
@EnhancedField()
name!: string;
@EnhancedField()
price!: number;
@Field(() => GraphQLISODateTime)
created!: Date;
@Field(() => GraphQLISODateTime)
updated!: Date;
}

In the following examples you will see two endpoints referenced:

  • product - GraphQL endpoint to find a record by id.
  • products - GraphQL endpoint to filter, page, and sort records.