feat: add makers resolver to project query api

This commit is contained in:
MTG2000
2022-09-18 15:51:42 +03:00
parent f22498aca1
commit 61b2e38651
3 changed files with 46 additions and 0 deletions

View File

@@ -279,6 +279,10 @@ export interface NexusGenObjects {
votes_count: number; // Int!
website: string; // String!
}
ProjectMember: { // root type
role: NexusGenEnums['TEAM_MEMBER_ROLE']; // TEAM_MEMBER_ROLE!
user: NexusGenRootTypes['User']; // User!
}
Query: {};
Question: { // root type
body: string; // String!
@@ -564,6 +568,7 @@ export interface NexusGenFieldTypes {
id: number; // Int!
lightning_address: string | null; // String
lnurl_callback_url: string | null; // String
memebrs: NexusGenRootTypes['ProjectMember'][]; // [ProjectMember!]!
recruit_roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
screenshots: string[]; // [String!]!
tags: NexusGenRootTypes['Tag'][]; // [Tag!]!
@@ -572,6 +577,10 @@ export interface NexusGenFieldTypes {
votes_count: number; // Int!
website: string; // String!
}
ProjectMember: { // field return type
role: NexusGenEnums['TEAM_MEMBER_ROLE']; // TEAM_MEMBER_ROLE!
user: NexusGenRootTypes['User']; // User!
}
Query: { // field return type
allCategories: NexusGenRootTypes['Category'][]; // [Category!]!
allProjects: NexusGenRootTypes['Project'][]; // [Project!]!
@@ -934,6 +943,7 @@ export interface NexusGenFieldTypeNames {
id: 'Int'
lightning_address: 'String'
lnurl_callback_url: 'String'
memebrs: 'ProjectMember'
recruit_roles: 'MakerRole'
screenshots: 'String'
tags: 'Tag'
@@ -942,6 +952,10 @@ export interface NexusGenFieldTypeNames {
votes_count: 'Int'
website: 'String'
}
ProjectMember: { // field return type name
role: 'TEAM_MEMBER_ROLE'
user: 'User'
}
Query: { // field return type name
allCategories: 'Category'
allProjects: 'Project'

View File

@@ -288,6 +288,7 @@ type Project {
id: Int!
lightning_address: String
lnurl_callback_url: String
memebrs: [ProjectMember!]!
recruit_roles: [MakerRole!]!
screenshots: [String!]!
tags: [Tag!]!
@@ -302,6 +303,11 @@ enum ProjectLaunchStatusEnum {
WIP
}
type ProjectMember {
role: TEAM_MEMBER_ROLE!
user: User!
}
type Query {
allCategories: [Category!]!
allProjects(skip: Int = 0, take: Int = 50): [Project!]!

View File

@@ -17,6 +17,7 @@ const { ImageInput } = require('./misc');
const { MakerRole } = require('./users');
const Project = objectType({
name: 'Project',
definition(t) {
@@ -73,6 +74,20 @@ const Project = objectType({
}
})
t.nonNull.list.nonNull.field('memebrs', {
type: ProjectMember,
resolve: (parent) => {
return prisma.projectMember.findMany({
where: {
projectId: parent.id
},
include: {
user: true
}
})
}
})
t.nonNull.list.nonNull.field('recruit_roles', {
type: MakerRole,
resolve: async (parent) => {
@@ -102,6 +117,17 @@ const TEAM_MEMBER_ROLE = enumType({
members: ['Admin', 'Maker'],
});
const ProjectMember = objectType({
name: "ProjectMember",
definition(t) {
t.nonNull.field('user', {
type: "User"
})
t.nonNull.field("role", {
type: TEAM_MEMBER_ROLE
})
}
})
const Award = objectType({