big gift
This commit is contained in:
@@ -13,6 +13,11 @@ import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
||||
import type { FileUpload } from 'graphql-upload/processRequest.js';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import SimpleObjectPlugin from '@pothos/plugin-simple-objects';
|
||||
import SmartSubscriptionPlugin, {
|
||||
subscribeOptionsFromIterator,
|
||||
} from '@pothos/plugin-smart-subscriptions';
|
||||
import RelayPlugin from '@pothos/plugin-relay';
|
||||
export interface SchemaContext {
|
||||
req: Request;
|
||||
res: Response;
|
||||
@@ -24,6 +29,9 @@ export interface SchemaBuilderOption {
|
||||
Context: SchemaContext;
|
||||
PrismaTypes: PrismaTypes;
|
||||
DataModel: PothosPrismaDatamodel;
|
||||
Connection: {
|
||||
totalCount: number | (() => number | Promise<number>);
|
||||
};
|
||||
Scalars: {
|
||||
DateTime: {
|
||||
Input: Date;
|
||||
@@ -46,7 +54,20 @@ export class Builder extends SchemaBuilder<SchemaBuilderOption> {
|
||||
|
||||
constructor(private readonly prisma: PrismaClient) {
|
||||
super({
|
||||
plugins: [PrismaPlugin, PrismaUtils],
|
||||
plugins: [
|
||||
PrismaPlugin,
|
||||
PrismaUtils,
|
||||
SimpleObjectPlugin,
|
||||
SmartSubscriptionPlugin,
|
||||
RelayPlugin,
|
||||
],
|
||||
smartSubscriptions: {
|
||||
debounceDelay: 1000,
|
||||
...subscribeOptionsFromIterator((name, { pubSub }) => {
|
||||
return pubSub.asyncIterator(name);
|
||||
}),
|
||||
},
|
||||
relay: {},
|
||||
prisma: {
|
||||
client: prisma,
|
||||
exposeDescriptions: true,
|
||||
@@ -62,6 +83,19 @@ export class Builder extends SchemaBuilder<SchemaBuilderOption> {
|
||||
|
||||
this.queryType({});
|
||||
this.mutationType({});
|
||||
// this.subscriptionType({});
|
||||
|
||||
this.globalConnectionField('totalCount', (t) =>
|
||||
t.int({
|
||||
nullable: true,
|
||||
resolve: (parent) =>
|
||||
typeof parent.totalCount === 'function'
|
||||
? parent.totalCount()
|
||||
: parent.totalCount,
|
||||
}),
|
||||
);
|
||||
|
||||
// test print ManagedServiceWhereUniqueInput
|
||||
}
|
||||
}
|
||||
export type BuilderTypes =
|
||||
|
||||
Reference in New Issue
Block a user