Skip to content

Instantly share code, notes, and snippets.

@martijnvdbrug
Last active March 1, 2019 12:58
Show Gist options
  • Save martijnvdbrug/86c12c5cb2a0ff07c3874ca8a697fcb2 to your computer and use it in GitHub Desktop.
Save martijnvdbrug/86c12c5cb2a0ff07c3874ca8a697fcb2 to your computer and use it in GitHub Desktop.
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