Last active
March 1, 2019 12:58
-
-
Save martijnvdbrug/86c12c5cb2a0ff07c3874ca8a697fcb2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 {Module} from '@nestjs/common'; | |
import {Tesla, Wheel} from '../../generated/graphql-types'; | |
import shortid = require('shortid'); | |
class IResolvers { | |
} | |
@Module({ | |
providers: [], | |
exports: [] | |
}) | |
export class TeslaModule { | |
static tesla: Tesla = { | |
id: shortid.generate(), | |
edition: 'Long range performance', | |
model: 'Model 3', | |
kwh: 74, | |
range: 470 | |
}; | |
static wheel: Wheel = { | |
id: shortid.generate(), | |
inch: 42, | |
name: 'Nitrogen cold gas thruster' | |
}; | |
static get resolvers(): IResolvers { | |
return { | |
Query: { | |
Tesla: async (_, {model}, {headers, auth}, info) => this.tesla | |
}, | |
Mutation: { | |
pimpMyWheels: async (_, {model}, {headers, auth}, info) => this.tesla | |
}, | |
Tesla: { | |
wheels: (tesla: Tesla) => this.wheel | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment