This commit is contained in:
Fre Timmerman 2021-02-05 15:24:02 +01:00
parent c7ee3ffb7c
commit 3f70e2a67e
4 changed files with 90 additions and 29 deletions

60
gql commands Normal file
View File

@ -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"}

View File

@ -16,6 +16,7 @@
"graphql": "^15.5.0",
"reflect-metadata": "^0.1.13",
"type-graphql": "^1.1.1",
"typescript": "^4.1.3",
"uuid": "^3.3.2",
"yup": "^0.32.8"
},

View File

@ -10,61 +10,61 @@ scalar DateTime
type Mutation {
"""Create a new reservation"""
createReservation(input: ReservationInput!): Reservation!
createReservation(input: ReservationInput): Reservation
"""Create a new store"""
createStore(input: StoreInput!): Store!
createStore(input: StoreInput): Store
}
type Product {
description: String!
id: String!
name: String!
price: Float!
description: String
id: String
name: String
price: Float
}
type Query {
"""Get a specific store"""
store(id: String!): Store!
store(id: String): Store
"""Get all the stores"""
stores: [Store!]!
stores: [Store]
}
type Reservation {
date: DateTime!
id: String!
reservationProducts: [ReservationProduct!]!
date: DateTime
id: String
reservationProducts: [ReservationProduct]
}
input ReservationInput {
reservationProducts: [ReservationProductInput!]!
reservationProducts: [ReservationProductInput]
}
type ReservationProduct {
product: Product!
quantity: Int!
product: Product
quantity: Int
}
input ReservationProductInput {
productId: String!
quantity: Int!
productId: String
quantity: Int
}
type Store {
city: String!
id: String!
name: String!
number: Int!
postalCode: String!
products: [Product!]!
street: String!
city: String
id: String
name: String
number: Int
postalCode: String
products: [Product]
street: String
}
input StoreInput {
city: String!
name: String!
number: Int!
postalCode: String!
street: String!
city: String
name: String
number: Int
postalCode: String
street: String
}

View File

@ -30,7 +30,7 @@ import { StoreResolver, ReservationResolver } from './resolvers.js';
// create the schema using TypeGraphQL, pass the resolver
const schema = await buildSchema({
resolvers: [StoreResolver, ReservationResolver],
//nullableByDefault: true,
nullableByDefault: true,
emitSchemaFile: path.resolve(".", "schema.gql"),
});