Marc
02/18/2019, 2:57 PMHarshit
02/18/2019, 3:25 PMimport { Injectable, Logger } from '@nestjs/common';
import { GqlOptionsFactory, GqlModuleOptions } from '@nestjs/graphql';
import { makeSchema } from 'nexus';
@Injectable()
export class GraphqlConfigService implements GqlOptionsFactory {
async createGqlOptions(): Promise<GqlModuleOptions> {
const schema = makeSchema({
types: [Account, Node, Query, StatusEnum],
// or types: { Account, Node, Query }
// or types: [Account, [Node], { Query }]
});
return {
debug: true,
playground: true,
schema,
};
}
}
And then in the app.module...
imports: [
GraphQLModule.forRootAsync({
useClass: GraphqlConfigService,
}),
],
Marc
02/18/2019, 5:38 PMMarc
02/18/2019, 7:17 PMimport { Injectable } from '@nestjs/common';
import { GqlOptionsFactory, GqlModuleOptions } from '@nestjs/graphql';
import { makePrismaSchema, prismaObjectType } from 'nexus-prisma';
import * as path from 'path';
import { prisma } from './client';
import datamodelInfo from './nexus/datamodel-info';
@Injectable()
export class GraphqlConfigService implements GqlOptionsFactory {
async createGqlOptions(): Promise<GqlModuleOptions> {
const Query = prismaObjectType({
name: 'Query',
definition(t) {
t.prismaFields(['*'])
}
});
const Mutation = prismaObjectType({
name: 'Mutation',
definition(t) {
t.prismaFields(['*'])
}
})
const schema = makePrismaSchema({
types: [Query, Mutation],
prisma: {
datamodelInfo,
client: prisma
},
outputs: {
schema: path.join(__dirname, './schema.graphql'),
typegen: path.join(__dirname, './nexus.ts'),
},
});
return {
debug: true,
playground: true,
schema,
};
}
}
Marc
02/18/2019, 7:17 PMMarc
02/18/2019, 8:57 PMHarshit
02/19/2019, 5:16 AMMarc
03/06/2019, 10:18 PMMarc
03/06/2019, 10:19 PMResolver
and Query
from nestjs. Do you have an idea?