-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
43 lines (38 loc) · 972 Bytes
/
schema.js
File metadata and controls
43 lines (38 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const {gql} = require ('apollo-server');
// Define the Type Definitions by providing them inside the backticks.
// In here we specify all of the things that we're able to fetch.
exports.typeDefs = gql`
type Query {
products(filter: ProductsFilterInput): [Product!]!
product(id: ID!): Product
categories: [Category!]!
category(id: ID!): Category
}
type Product {
id: ID!
name: String!
description: String!
image: String!
quantity: Int!
price: Float!
onSale: Boolean!
category: Category
reviews: [Review!]!
}
type Category {
id: ID!
name: String!
products(filter: ProductsFilterInput): [Product!]!
}
type Review {
id: ID!
date: String!
title: String!
comment: String!
rating: Int!
}
input ProductsFilterInput {
onSale: Boolean
avgRating: Int
}
`