Last active
October 3, 2020 17:27
-
-
Save jsoneaday/b5681aca1b4c78b2af9137ac071ff562 to your computer and use it in GitHub Desktop.
Vehicle Interface Schema
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
import { gql } from "apollo-server-express"; | |
const typeDefs = gql` | |
scalar Void | |
interface IVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
} | |
interface IPassengerVehicle implements IVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
passengerCount: Int | |
} | |
interface IWorkVehicle implements IVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
maxPayload: Float | |
} | |
interface ILandVehicle implements IVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
wheelCount: Int | |
} | |
type Car implements IVehicle & IPassengerVehicle & ILandVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
wheelCount: Int | |
passengerCount: Int | |
} | |
type Truck implements IVehicle & IWorkVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
wheelCount: Int | |
maxPayload: Float | |
} | |
type Boat implements IVehicle & IPassengerVehicle { | |
id: ID! | |
name: String! | |
desc: String! | |
passengerCount: Int | |
} | |
union SearchResult = Car | Truck | Boat | |
type Query { | |
getAllVehicles: [SearchResult!] | |
} | |
`; | |
export default typeDefs; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment