fix: handle different prisma clients types

This commit is contained in:
MTG2000
2022-09-25 12:07:30 +03:00
parent 4b4036fc57
commit 3fd0b27a84
4 changed files with 38 additions and 29 deletions

View File

@@ -131,6 +131,7 @@ export interface NexusGenInputs {
export interface NexusGenEnums {
POST_TYPE: "Bounty" | "Question" | "Story"
ProjectLaunchStatusEnum: "Launched" | "WIP"
ProjectPermissionEnum: "DeleteProject" | "UpdateAdmins" | "UpdateInfo" | "UpdateMembers"
RoleLevelEnum: 3 | 0 | 1 | 2 | 4
TEAM_MEMBER_ROLE: "Admin" | "Maker" | "Owner"
TournamentEventTypeEnum: 2 | 3 | 0 | 1
@@ -283,7 +284,6 @@ export interface NexusGenObjects {
tagline: string; // String!
telegram?: string | null; // String
title: string; // String!
tournaments?: NexusGenRootTypes['TournamentProject'][] | null; // [TournamentProject!]
twitter?: string | null; // String
votes_count: number; // Int!
website: string; // String!
@@ -361,10 +361,6 @@ export interface NexusGenObjects {
amount: string; // String!
title: string; // String!
}
TournamentProject: { // root type
project: NexusGenRootTypes['Project']; // Project!
tournament: NexusGenRootTypes['Tournament']; // Tournament!
}
TournamentProjectsResponse: { // root type
hasNext?: boolean | null; // Boolean
hasPrev?: boolean | null; // Boolean
@@ -587,6 +583,7 @@ export interface NexusGenFieldTypes {
lightning_address: string | null; // String
lnurl_callback_url: string | null; // String
members: NexusGenRootTypes['ProjectMember'][]; // [ProjectMember!]!
permissions: NexusGenEnums['ProjectPermissionEnum'][]; // [ProjectPermissionEnum!]!
recruit_roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
screenshots: string[]; // [String!]!
slack: string | null; // String
@@ -595,7 +592,7 @@ export interface NexusGenFieldTypes {
telegram: string | null; // String
thumbnail_image: string; // String!
title: string; // String!
tournaments: NexusGenRootTypes['TournamentProject'][] | null; // [TournamentProject!]
tournaments: NexusGenRootTypes['Tournament'][]; // [Tournament!]!
twitter: string | null; // String
votes_count: number; // Int!
website: string; // String!
@@ -726,10 +723,6 @@ export interface NexusGenFieldTypes {
image: string; // String!
title: string; // String!
}
TournamentProject: { // field return type
project: NexusGenRootTypes['Project']; // Project!
tournament: NexusGenRootTypes['Tournament']; // Tournament!
}
TournamentProjectsResponse: { // field return type
hasNext: boolean | null; // Boolean
hasPrev: boolean | null; // Boolean
@@ -978,6 +971,7 @@ export interface NexusGenFieldTypeNames {
lightning_address: 'String'
lnurl_callback_url: 'String'
members: 'ProjectMember'
permissions: 'ProjectPermissionEnum'
recruit_roles: 'MakerRole'
screenshots: 'String'
slack: 'String'
@@ -986,7 +980,7 @@ export interface NexusGenFieldTypeNames {
telegram: 'String'
thumbnail_image: 'String'
title: 'String'
tournaments: 'TournamentProject'
tournaments: 'Tournament'
twitter: 'String'
votes_count: 'Int'
website: 'String'
@@ -1117,10 +1111,6 @@ export interface NexusGenFieldTypeNames {
image: 'String'
title: 'String'
}
TournamentProject: { // field return type name
project: 'Project'
tournament: 'Tournament'
}
TournamentProjectsResponse: { // field return type name
hasNext: 'Boolean'
hasPrev: 'Boolean'

View File

@@ -294,6 +294,7 @@ type Project {
lightning_address: String
lnurl_callback_url: String
members: [ProjectMember!]!
permissions: [ProjectPermissionEnum!]!
recruit_roles: [MakerRole!]!
screenshots: [String!]!
slack: String
@@ -302,7 +303,7 @@ type Project {
telegram: String
thumbnail_image: String!
title: String!
tournaments: [TournamentProject!]
tournaments: [Tournament!]!
twitter: String
votes_count: Int!
website: String!
@@ -318,6 +319,13 @@ type ProjectMember {
user: User!
}
enum ProjectPermissionEnum {
DeleteProject
UpdateAdmins
UpdateInfo
UpdateMembers
}
type Query {
allCategories: [Category!]!
allProjects(skip: Int = 0, take: Int = 50): [Project!]!
@@ -496,11 +504,6 @@ type TournamentPrize {
title: String!
}
type TournamentProject {
project: Project!
tournament: Tournament!
}
type TournamentProjectsResponse {
hasNext: Boolean
hasPrev: Boolean

View File

@@ -1,15 +1,21 @@
const { PrismaClient } = require('@prisma/client/edge');
const { PrismaClient } = process.env.NODE_ENV === 'development' ? require('@prisma/client') : require('@prisma/client/edge');
const createGlobalModule = require('../utils/createGlobalModule');
const createPrismaClient = () => {
console.log("New Prisma Client");
return new PrismaClient({
log: ["info"],
});
try {
return new PrismaClient({
log: ["info"],
});
} catch (error) {
console.log(error);
}
}
const prisma = createGlobalModule('prisma', createPrismaClient)
module.exports = {
prisma
}

View File

@@ -219,7 +219,7 @@ export type Mutation = {
confirmVote: Vote;
createProject: Maybe<CreateProjectResponse>;
createStory: Maybe<Story>;
deleteProject: Maybe<CreateProjectResponse>;
deleteProject: Maybe<Project>;
deleteStory: Maybe<Story>;
donate: Donation;
registerInTournament: Maybe<User>;
@@ -411,6 +411,7 @@ export type Project = {
lightning_address: Maybe<Scalars['String']>;
lnurl_callback_url: Maybe<Scalars['String']>;
members: Array<ProjectMember>;
permissions: Array<ProjectPermissionEnum>;
recruit_roles: Array<MakerRole>;
screenshots: Array<Scalars['String']>;
slack: Maybe<Scalars['String']>;
@@ -419,6 +420,7 @@ export type Project = {
telegram: Maybe<Scalars['String']>;
thumbnail_image: Scalars['String'];
title: Scalars['String'];
tournaments: Array<Tournament>;
twitter: Maybe<Scalars['String']>;
votes_count: Scalars['Int'];
website: Scalars['String'];
@@ -435,6 +437,13 @@ export type ProjectMember = {
user: User;
};
export enum ProjectPermissionEnum {
DeleteProject = 'DeleteProject',
UpdateAdmins = 'UpdateAdmins',
UpdateInfo = 'UpdateInfo',
UpdateMembers = 'UpdateMembers'
}
export type Query = {
__typename?: 'Query';
allCategories: Array<Category>;
@@ -647,9 +656,9 @@ export type StoryInputType = {
};
export enum Team_Member_Role {
Owner = 'Owner',
Admin = 'Admin',
Maker = 'Maker'
Maker = 'Maker',
Owner = 'Owner'
}
export type Tag = {
@@ -1063,7 +1072,7 @@ export type ProjectDetailsQueryVariables = Exact<{
}>;
export type ProjectDetailsQuery = { __typename?: 'Query', getProject: { __typename?: 'Project', id: number, title: string, tagline: string, description: string, hashtag: string, cover_image: string, thumbnail_image: string, launch_status: ProjectLaunchStatusEnum, twitter: string | null, discord: string | null, github: string | null, slack: string | null, telegram: string | null, screenshots: Array<string>, website: string, lightning_address: string | null, votes_count: number, category: { __typename?: 'Category', id: number, icon: string | null, title: string }, members: Array<{ __typename?: 'ProjectMember', role: Team_Member_Role, user: { __typename?: 'User', id: number, name: string, jobTitle: string | null, avatar: string } }>, awards: Array<{ __typename?: 'Award', title: string, image: string, url: string, id: number }>, tags: Array<{ __typename?: 'Tag', id: number, title: string }>, recruit_roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }>, capabilities: Array<{ __typename?: 'Capability', id: number, title: string, icon: string }> } };
export type ProjectDetailsQuery = { __typename?: 'Query', getProject: { __typename?: 'Project', id: number, title: string, tagline: string, description: string, hashtag: string, cover_image: string, thumbnail_image: string, launch_status: ProjectLaunchStatusEnum, twitter: string | null, discord: string | null, github: string | null, slack: string | null, telegram: string | null, screenshots: Array<string>, website: string, lightning_address: string | null, votes_count: number, permissions: Array<ProjectPermissionEnum>, category: { __typename?: 'Category', id: number, icon: string | null, title: string }, members: Array<{ __typename?: 'ProjectMember', role: Team_Member_Role, user: { __typename?: 'User', id: number, name: string, jobTitle: string | null, avatar: string } }>, awards: Array<{ __typename?: 'Award', title: string, image: string, url: string, id: number }>, tags: Array<{ __typename?: 'Tag', id: number, title: string }>, recruit_roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }>, capabilities: Array<{ __typename?: 'Capability', id: number, title: string, icon: string }> } };
export type GetAllRolesQueryVariables = Exact<{ [key: string]: never; }>;
@@ -2714,6 +2723,7 @@ export const ProjectDetailsDocument = gql`
icon
title
}
permissions
members {
role
user {