extra
This commit is contained in:
parent
c7ee3ffb7c
commit
3f70e2a67e
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
stores{
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
city,
|
||||||
|
number,
|
||||||
|
postalCode,
|
||||||
|
street,
|
||||||
|
products{description,name,price}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation{
|
||||||
|
createStore(
|
||||||
|
input:{
|
||||||
|
name: "asdf",
|
||||||
|
city: "asdf",
|
||||||
|
number:2,
|
||||||
|
postalCode: "hallohallo",
|
||||||
|
street: "asdf"
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
city,
|
||||||
|
number,
|
||||||
|
postalCode,
|
||||||
|
street
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query getStore($storeId: String!, $withProducts: Boolean!){
|
||||||
|
store (id:$storeId){
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
city,
|
||||||
|
number,
|
||||||
|
postalCode,
|
||||||
|
street,
|
||||||
|
products @include(if: $withProducts) {id,description,name,price}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var {"storeId": "5f2919aa-333a-4745-8166-3002ab30de0e","withProducts":true}
|
||||||
|
|
||||||
|
mutation($productId:String!){
|
||||||
|
createReservation(
|
||||||
|
input:{
|
||||||
|
reservationProducts:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
productId:$productId,
|
||||||
|
quantity:2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id,date,reservationProducts{product{name,description,price},quantity}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var {"productId":"5bb3fbcc-7ec2-44fe-a04b-a0251cecf1e6"}
|
|
@ -16,6 +16,7 @@
|
||||||
"graphql": "^15.5.0",
|
"graphql": "^15.5.0",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"type-graphql": "^1.1.1",
|
"type-graphql": "^1.1.1",
|
||||||
|
"typescript": "^4.1.3",
|
||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
"yup": "^0.32.8"
|
"yup": "^0.32.8"
|
||||||
},
|
},
|
||||||
|
|
56
schema.gql
56
schema.gql
|
@ -10,61 +10,61 @@ scalar DateTime
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
"""Create a new reservation"""
|
"""Create a new reservation"""
|
||||||
createReservation(input: ReservationInput!): Reservation!
|
createReservation(input: ReservationInput): Reservation
|
||||||
|
|
||||||
"""Create a new store"""
|
"""Create a new store"""
|
||||||
createStore(input: StoreInput!): Store!
|
createStore(input: StoreInput): Store
|
||||||
}
|
}
|
||||||
|
|
||||||
type Product {
|
type Product {
|
||||||
description: String!
|
description: String
|
||||||
id: String!
|
id: String
|
||||||
name: String!
|
name: String
|
||||||
price: Float!
|
price: Float
|
||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
"""Get a specific store"""
|
"""Get a specific store"""
|
||||||
store(id: String!): Store!
|
store(id: String): Store
|
||||||
|
|
||||||
"""Get all the stores"""
|
"""Get all the stores"""
|
||||||
stores: [Store!]!
|
stores: [Store]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Reservation {
|
type Reservation {
|
||||||
date: DateTime!
|
date: DateTime
|
||||||
id: String!
|
id: String
|
||||||
reservationProducts: [ReservationProduct!]!
|
reservationProducts: [ReservationProduct]
|
||||||
}
|
}
|
||||||
|
|
||||||
input ReservationInput {
|
input ReservationInput {
|
||||||
reservationProducts: [ReservationProductInput!]!
|
reservationProducts: [ReservationProductInput]
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReservationProduct {
|
type ReservationProduct {
|
||||||
product: Product!
|
product: Product
|
||||||
quantity: Int!
|
quantity: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
input ReservationProductInput {
|
input ReservationProductInput {
|
||||||
productId: String!
|
productId: String
|
||||||
quantity: Int!
|
quantity: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Store {
|
type Store {
|
||||||
city: String!
|
city: String
|
||||||
id: String!
|
id: String
|
||||||
name: String!
|
name: String
|
||||||
number: Int!
|
number: Int
|
||||||
postalCode: String!
|
postalCode: String
|
||||||
products: [Product!]!
|
products: [Product]
|
||||||
street: String!
|
street: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input StoreInput {
|
input StoreInput {
|
||||||
city: String!
|
city: String
|
||||||
name: String!
|
name: String
|
||||||
number: Int!
|
number: Int
|
||||||
postalCode: String!
|
postalCode: String
|
||||||
street: String!
|
street: String
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { StoreResolver, ReservationResolver } from './resolvers.js';
|
||||||
// create the schema using TypeGraphQL, pass the resolver
|
// create the schema using TypeGraphQL, pass the resolver
|
||||||
const schema = await buildSchema({
|
const schema = await buildSchema({
|
||||||
resolvers: [StoreResolver, ReservationResolver],
|
resolvers: [StoreResolver, ReservationResolver],
|
||||||
//nullableByDefault: true,
|
nullableByDefault: true,
|
||||||
emitSchemaFile: path.resolve(".", "schema.gql"),
|
emitSchemaFile: path.resolve(".", "schema.gql"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue