Skip to content

Instantly share code, notes, and snippets.

@jsoneaday
Last active October 3, 2020 17:27
Show Gist options
  • Save jsoneaday/b5681aca1b4c78b2af9137ac071ff562 to your computer and use it in GitHub Desktop.
Save jsoneaday/b5681aca1b4c78b2af9137ac071ff562 to your computer and use it in GitHub Desktop.
Vehicle Interface Schema
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