food-graphql-server/src/typeDefs.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-02-04 18:08:19 +00:00
const { gql } = require('apollo-server');
// Type definitions define the "shape" of your data and specify
// which ways the data can be fetched from the GraphQL server.
module.exports = gql`
scalar DateTime
2019-02-04 18:08:19 +00:00
# Comments in GraphQL are defined with the hash (#) symbol.
2019-02-07 13:25:20 +00:00
type Product {
description: String
id: ID
2019-02-07 13:25:20 +00:00
name: String
price: Float
}
2019-02-04 18:08:19 +00:00
# This "Store" type can be used in other type declarations.
type Store {
2019-02-07 09:21:28 +00:00
city: String
id: ID
2019-02-04 18:08:19 +00:00
name: String
2019-02-07 09:21:28 +00:00
number: Int
postalCode: String
2019-02-07 13:25:20 +00:00
products: [Product]
2019-02-07 09:21:28 +00:00
street: String
2019-02-04 18:08:19 +00:00
}
2019-02-07 14:58:00 +00:00
type ReservationProduct {
product: Product
quantity: Int
}
type Reservation {
date: DateTime
id: ID
2019-02-07 14:58:00 +00:00
reservationProducts: [ReservationProduct]
}
2019-02-04 18:08:19 +00:00
# The "Query" type is the root of all GraphQL queries.
# (A "Mutation" type will be covered later on.)
type Query {
stores: [Store]
store(id: ID): Store
2019-02-04 18:08:19 +00:00
}
2019-02-07 09:21:28 +00:00
input StoreInput {
city: String
2019-02-07 14:55:48 +00:00
name: String!
2019-02-07 09:21:28 +00:00
number: Int
postalCode: String
street: String
}
2019-02-07 14:58:00 +00:00
input ReservationProductInput {
2019-02-13 12:00:33 +00:00
productId: ID
2019-02-07 14:58:00 +00:00
quantity: Int
}
input ReservationInput {
reservationProducts: [ReservationProductInput]
}
2019-02-07 09:21:28 +00:00
type Mutation {
createStore(input: StoreInput): Store
2019-02-07 14:58:00 +00:00
createReservation(input: ReservationInput): Reservation
2019-02-07 09:21:28 +00:00
}
2019-02-04 18:08:19 +00:00
`;