food-graphql-server/src/typeDefs.ts

49 lines
858 B
TypeScript
Raw Normal View History

2021-02-01 13:36:26 +00:00
// Type definitions define the "shape" of your data and specify
// which ways the data can be fetched from the GraphQL server.
import "reflect-metadata";
2021-02-02 14:08:42 +00:00
import { ObjectType, Field, InputType, Int, Float } from "type-graphql";
2021-02-01 13:36:26 +00:00
@ObjectType()
export class Store {
2021-02-02 10:34:34 +00:00
@Field()
2021-02-01 13:36:26 +00:00
id: string;
2021-02-02 10:34:34 +00:00
@Field()
name: string;
@Field()
city: string;
@Field(type => Int)
number: number;
@Field()
postalCode: string
@Field()
street: string
2021-02-02 14:08:42 +00:00
@Field(type => [Product])
products?: [Product]
2021-02-02 10:34:34 +00:00
}
@InputType()
export class StoreInput {
@Field()
2021-02-01 13:36:26 +00:00
name: string;
2021-02-02 10:34:34 +00:00
@Field()
city: string;
@Field(type => Int)
number: number;
@Field()
postalCode: string
@Field()
street: string
2021-02-02 14:08:42 +00:00
}
@ObjectType()
export class Product {
@Field()
id: string;
@Field()
name: string;
@Field()
description: string;
@Field(type => Float)
price: number;
2021-02-01 13:36:26 +00:00
}