Created
January 13, 2021 02:59
-
-
Save reselbob/1dde70aaf0f1dfe8aba214c8890ea6fd to your computer and use it in GitHub Desktop.
A sample GraphQL type defintion file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {gql} = require('apollo-server'); | |
module.exports = gql` | |
"""A custom scalar that returns time data as JavaScript Date object""" | |
scalar Date | |
scalar Object | |
enum SeatStatus { | |
"""The seat is in the process of being released from RESERVED or SOLD status""" | |
RELEASING | |
"""The seat is open for reservation or sale.""" | |
OPEN | |
"""The seat is in the process of being reserved.""" | |
RESERVING | |
"""The seat has been reserved but not sold.""" | |
RESERVED | |
"""The seat is in the process of being sold.""" | |
SELLING | |
"""The seat has been sold.""" | |
SOLD | |
} | |
type Query { | |
venues: [Venue] | |
venue(id: ID!): Venue | |
soldSeats(venueId: ID!): [Seat] | |
reservedSeats(venueId: ID!): [Seat] | |
openSeats(venueId: ID!):[Seat] | |
} | |
type Mutation { | |
reserveSeat(seat: SeatInput): Seat | |
buySeat(seat: SeatInput): Seat | |
releaseSeat(seat: SeatInput): Seat | |
} | |
type Subscription { | |
onSeatReserved: SeatEvent | |
onSeatSold: SeatEvent | |
onSeatReleased: SeatEvent | |
} | |
"""A venue is a organizational unit for seats. For example, a venue can be an arena or an airplane.""" | |
type Venue { | |
id: ID | |
name: String | |
address: String | |
city: String | |
state_province: String | |
postal_code: String | |
country: String | |
seats: [Seat] | |
} | |
"""A seat in a venue""" | |
type Seat { | |
id:ID | |
number: String! | |
section: String! | |
status: SeatStatus! | |
customer: Customer | |
} | |
input SeatInput { | |
"""The system assigned unique identifier of a venue""" | |
venueId: ID! | |
"""The unique seat number""" | |
number: String! | |
"""The customer interested in the seat""" | |
customer: CustomerInput! | |
} | |
input CustomerInput { | |
firstName: String | |
lastName: String | |
email: String | |
} | |
"""A customer type known the system uniquely according to email address""" | |
type Customer { | |
firstName: String | |
lastName: String | |
email: String | |
} | |
""" An event that describes activity around a seat. The event is generated by the system and sent as a message in a subscription.""" | |
type SeatEvent { | |
message: String | |
venueId: ID | |
seatId: ID | |
number: String! | |
section: String | |
status: SeatStatus! | |
changeDate: Date | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment