feat: update roles card, mocks, schema, stories

This commit is contained in:
MTG2000
2022-08-22 13:34:30 +03:00
parent 80b7053f88
commit bb0fbfa572
15 changed files with 841 additions and 145 deletions

View File

@@ -28,6 +28,13 @@ declare global {
}
export interface NexusGenInputs {
MakerRoleInput: { // input type
id: number; // Int!
level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum!
}
MakerSkillInput: { // input type
id: number; // Int!
}
ProfileDetailsInput: { // input type
avatar?: string | null; // String
bio?: string | null; // String
@@ -41,6 +48,10 @@ export interface NexusGenInputs {
twitter?: string | null; // String
website?: string | null; // String
}
ProfileRolesInput: { // input type
roles: NexusGenInputs['MakerRoleInput'][]; // [MakerRoleInput!]!
skills: NexusGenInputs['MakerSkillInput'][]; // [MakerSkillInput!]!
}
StoryInputType: { // input type
body: string; // String!
cover_image?: string | null; // String
@@ -125,6 +136,11 @@ export interface NexusGenObjects {
prizes: string; // String!
touranments: string; // String!
}
GenericMakerRole: { // root type
icon: string; // String!
id: number; // Int!
title: string; // String!
}
Hackathon: { // root type
cover_image: string; // String!
description: string; // String!
@@ -141,6 +157,16 @@ export interface NexusGenObjects {
metadata?: string | null; // String
minSendable?: number | null; // Int
}
MakerRole: { // root type
icon: string; // String!
id: number; // Int!
level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum!
title: string; // String!
}
MakerSkill: { // root type
id: number; // Int!
title: string; // String!
}
Mutation: {};
MyProfile: { // root type
avatar: string; // String!
@@ -235,16 +261,6 @@ export interface NexusGenObjects {
twitter?: string | null; // String
website?: string | null; // String
}
UserRole: { // root type
icon: string; // String!
id: number; // Int!
level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum!
title: string; // String!
}
UserSkill: { // root type
id: number; // Int!
title: string; // String!
}
Vote: { // root type
amount_in_sat: number; // Int!
id: number; // Int!
@@ -336,6 +352,11 @@ export interface NexusGenFieldTypes {
prizes: string; // String!
touranments: string; // String!
}
GenericMakerRole: { // field return type
icon: string; // String!
id: number; // Int!
title: string; // String!
}
Hackathon: { // field return type
cover_image: string; // String!
description: string; // String!
@@ -353,6 +374,16 @@ export interface NexusGenFieldTypes {
metadata: string | null; // String
minSendable: number | null; // Int
}
MakerRole: { // field return type
icon: string; // String!
id: number; // Int!
level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum!
title: string; // String!
}
MakerSkill: { // field return type
id: number; // Int!
title: string; // String!
}
Mutation: { // field return type
confirmDonation: NexusGenRootTypes['Donation']; // Donation!
confirmVote: NexusGenRootTypes['Vote']; // Vote!
@@ -360,6 +391,7 @@ export interface NexusGenFieldTypes {
deleteStory: NexusGenRootTypes['Story'] | null; // Story
donate: NexusGenRootTypes['Donation']; // Donation!
updateProfileDetails: NexusGenRootTypes['MyProfile'] | null; // MyProfile
updateProfileRoles: NexusGenRootTypes['MyProfile'] | null; // MyProfile
updateUserPreferences: NexusGenRootTypes['MyProfile']; // MyProfile!
vote: NexusGenRootTypes['Vote']; // Vote!
}
@@ -378,9 +410,9 @@ export interface NexusGenFieldTypes {
nostr_prv_key: string | null; // String
nostr_pub_key: string | null; // String
role: string | null; // String
roles: NexusGenRootTypes['UserRole'][]; // [UserRole!]!
roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
similar_makers: NexusGenRootTypes['User'][]; // [User!]!
skills: NexusGenRootTypes['UserSkill'][]; // [UserSkill!]!
skills: NexusGenRootTypes['MakerSkill'][]; // [MakerSkill!]!
stories: NexusGenRootTypes['Story'][]; // [Story!]!
tournaments: NexusGenRootTypes['Tournament'][]; // [Tournament!]!
twitter: string | null; // String
@@ -414,6 +446,8 @@ export interface NexusGenFieldTypes {
allCategories: NexusGenRootTypes['Category'][]; // [Category!]!
allProjects: NexusGenRootTypes['Project'][]; // [Project!]!
getAllHackathons: NexusGenRootTypes['Hackathon'][]; // [Hackathon!]!
getAllMakersRoles: NexusGenRootTypes['GenericMakerRole'][]; // [GenericMakerRole!]!
getAllMakersSkills: NexusGenRootTypes['MakerSkill'][]; // [MakerSkill!]!
getCategory: NexusGenRootTypes['Category']; // Category!
getDonationsStats: NexusGenRootTypes['DonationsStats']; // DonationsStats!
getFeed: NexusGenRootTypes['Post'][]; // [Post!]!
@@ -492,24 +526,14 @@ export interface NexusGenFieldTypes {
location: string | null; // String
name: string; // String!
role: string | null; // String
roles: NexusGenRootTypes['UserRole'][]; // [UserRole!]!
roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
similar_makers: NexusGenRootTypes['User'][]; // [User!]!
skills: NexusGenRootTypes['UserSkill'][]; // [UserSkill!]!
skills: NexusGenRootTypes['MakerSkill'][]; // [MakerSkill!]!
stories: NexusGenRootTypes['Story'][]; // [Story!]!
tournaments: NexusGenRootTypes['Tournament'][]; // [Tournament!]!
twitter: string | null; // String
website: string | null; // String
}
UserRole: { // field return type
icon: string; // String!
id: number; // Int!
level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum!
title: string; // String!
}
UserSkill: { // field return type
id: number; // Int!
title: string; // String!
}
Vote: { // field return type
amount_in_sat: number; // Int!
id: number; // Int!
@@ -536,9 +560,9 @@ export interface NexusGenFieldTypes {
location: string | null; // String
name: string; // String!
role: string | null; // String
roles: NexusGenRootTypes['UserRole'][]; // [UserRole!]!
roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
similar_makers: NexusGenRootTypes['User'][]; // [User!]!
skills: NexusGenRootTypes['UserSkill'][]; // [UserSkill!]!
skills: NexusGenRootTypes['MakerSkill'][]; // [MakerSkill!]!
stories: NexusGenRootTypes['Story'][]; // [Story!]!
tournaments: NexusGenRootTypes['Tournament'][]; // [Tournament!]!
twitter: string | null; // String
@@ -619,6 +643,11 @@ export interface NexusGenFieldTypeNames {
prizes: 'String'
touranments: 'String'
}
GenericMakerRole: { // field return type name
icon: 'String'
id: 'Int'
title: 'String'
}
Hackathon: { // field return type name
cover_image: 'String'
description: 'String'
@@ -636,6 +665,16 @@ export interface NexusGenFieldTypeNames {
metadata: 'String'
minSendable: 'Int'
}
MakerRole: { // field return type name
icon: 'String'
id: 'Int'
level: 'RoleLevelEnum'
title: 'String'
}
MakerSkill: { // field return type name
id: 'Int'
title: 'String'
}
Mutation: { // field return type name
confirmDonation: 'Donation'
confirmVote: 'Vote'
@@ -643,6 +682,7 @@ export interface NexusGenFieldTypeNames {
deleteStory: 'Story'
donate: 'Donation'
updateProfileDetails: 'MyProfile'
updateProfileRoles: 'MyProfile'
updateUserPreferences: 'MyProfile'
vote: 'Vote'
}
@@ -661,9 +701,9 @@ export interface NexusGenFieldTypeNames {
nostr_prv_key: 'String'
nostr_pub_key: 'String'
role: 'String'
roles: 'UserRole'
roles: 'MakerRole'
similar_makers: 'User'
skills: 'UserSkill'
skills: 'MakerSkill'
stories: 'Story'
tournaments: 'Tournament'
twitter: 'String'
@@ -697,6 +737,8 @@ export interface NexusGenFieldTypeNames {
allCategories: 'Category'
allProjects: 'Project'
getAllHackathons: 'Hackathon'
getAllMakersRoles: 'GenericMakerRole'
getAllMakersSkills: 'MakerSkill'
getCategory: 'Category'
getDonationsStats: 'DonationsStats'
getFeed: 'Post'
@@ -775,24 +817,14 @@ export interface NexusGenFieldTypeNames {
location: 'String'
name: 'String'
role: 'String'
roles: 'UserRole'
roles: 'MakerRole'
similar_makers: 'User'
skills: 'UserSkill'
skills: 'MakerSkill'
stories: 'Story'
tournaments: 'Tournament'
twitter: 'String'
website: 'String'
}
UserRole: { // field return type name
icon: 'String'
id: 'Int'
level: 'RoleLevelEnum'
title: 'String'
}
UserSkill: { // field return type name
id: 'Int'
title: 'String'
}
Vote: { // field return type name
amount_in_sat: 'Int'
id: 'Int'
@@ -819,9 +851,9 @@ export interface NexusGenFieldTypeNames {
location: 'String'
name: 'String'
role: 'String'
roles: 'UserRole'
roles: 'MakerRole'
similar_makers: 'User'
skills: 'UserSkill'
skills: 'MakerSkill'
stories: 'Story'
tournaments: 'Tournament'
twitter: 'String'
@@ -861,6 +893,9 @@ export interface NexusGenArgTypes {
updateProfileDetails: { // args
data?: NexusGenInputs['ProfileDetailsInput'] | null; // ProfileDetailsInput
}
updateProfileRoles: { // args
data?: NexusGenInputs['ProfileRolesInput'] | null; // ProfileRolesInput
}
updateUserPreferences: { // args
userKeys?: NexusGenInputs['UserKeyInputType'][] | null; // [UserKeyInputType!]
}

View File

@@ -31,9 +31,9 @@ interface BaseUser {
location: String
name: String!
role: String
roles: [UserRole!]!
roles: [MakerRole!]!
similar_makers: [User!]!
skills: [UserSkill!]!
skills: [MakerSkill!]!
stories: [Story!]!
tournaments: [Tournament!]!
twitter: String
@@ -96,6 +96,12 @@ type DonationsStats {
touranments: String!
}
type GenericMakerRole {
icon: String!
id: Int!
title: String!
}
type Hackathon {
cover_image: String!
description: String!
@@ -115,6 +121,27 @@ type LnurlDetails {
minSendable: Int
}
type MakerRole {
icon: String!
id: Int!
level: RoleLevelEnum!
title: String!
}
input MakerRoleInput {
id: Int!
level: RoleLevelEnum!
}
type MakerSkill {
id: Int!
title: String!
}
input MakerSkillInput {
id: Int!
}
type Mutation {
confirmDonation(payment_request: String!, preimage: String!): Donation!
confirmVote(payment_request: String!, preimage: String!): Vote!
@@ -122,6 +149,7 @@ type Mutation {
deleteStory(id: Int!): Story
donate(amount_in_sat: Int!): Donation!
updateProfileDetails(data: ProfileDetailsInput): MyProfile
updateProfileRoles(data: ProfileRolesInput): MyProfile
updateUserPreferences(userKeys: [UserKeyInputType!]): MyProfile!
vote(amount_in_sat: Int!, item_id: Int!, item_type: VOTE_ITEM_TYPE!): Vote!
}
@@ -141,9 +169,9 @@ type MyProfile implements BaseUser {
nostr_prv_key: String
nostr_pub_key: String
role: String
roles: [UserRole!]!
roles: [MakerRole!]!
similar_makers: [User!]!
skills: [UserSkill!]!
skills: [MakerSkill!]!
stories: [Story!]!
tournaments: [Tournament!]!
twitter: String
@@ -193,6 +221,11 @@ input ProfileDetailsInput {
website: String
}
input ProfileRolesInput {
roles: [MakerRoleInput!]!
skills: [MakerSkillInput!]!
}
type Project {
awards: [Award!]!
category: Category!
@@ -213,6 +246,8 @@ type Query {
allCategories: [Category!]!
allProjects(skip: Int = 0, take: Int = 50): [Project!]!
getAllHackathons(sortBy: String, tag: Int): [Hackathon!]!
getAllMakersRoles: [GenericMakerRole!]!
getAllMakersSkills: [MakerSkill!]!
getCategory(id: Int!): Category!
getDonationsStats: DonationsStats!
getFeed(skip: Int = 0, sortBy: String, tag: Int = 0, take: Int = 10): [Post!]!
@@ -313,9 +348,9 @@ type User implements BaseUser {
location: String
name: String!
role: String
roles: [UserRole!]!
roles: [MakerRole!]!
similar_makers: [User!]!
skills: [UserSkill!]!
skills: [MakerSkill!]!
stories: [Story!]!
tournaments: [Tournament!]!
twitter: String
@@ -327,18 +362,6 @@ input UserKeyInputType {
name: String!
}
type UserRole {
icon: String!
id: Int!
level: RoleLevelEnum!
title: String!
}
type UserSkill {
id: Int!
title: String!
}
enum VOTE_ITEM_TYPE {
Bounty
PostComment

View File

@@ -26,13 +26,13 @@ const BaseUser = interfaceType({
t.string('bio')
t.string('location')
t.nonNull.list.nonNull.field('roles', {
type: UserRole,
type: MakerRole,
resolve: (parent) => {
return []
}
})
t.nonNull.list.nonNull.field('skills', {
type: UserSkill,
type: MakerSkill,
resolve: (parent) => {
return []
}
@@ -74,6 +74,8 @@ const BaseUser = interfaceType({
},
})
const RoleLevelEnum = enumType({
name: 'RoleLevelEnum',
members: {
@@ -85,8 +87,17 @@ const RoleLevelEnum = enumType({
},
});
const UserRole = objectType({
name: 'UserRole',
const GenericMakerRole = objectType({
name: 'GenericMakerRole',
definition(t) {
t.nonNull.int('id');
t.nonNull.string('title');
t.nonNull.string('icon');
}
})
const MakerRole = objectType({
name: 'MakerRole',
definition(t) {
t.nonNull.int('id');
t.nonNull.string('title');
@@ -95,14 +106,40 @@ const UserRole = objectType({
}
})
const UserSkill = objectType({
name: 'UserSkill',
const getAllMakersRoles = extendType({
type: "Query",
definition(t) {
t.nonNull.list.nonNull.field('getAllMakersRoles', {
type: GenericMakerRole,
async resolve(parent, args, context) {
return []
}
})
}
})
const MakerSkill = objectType({
name: 'MakerSkill',
definition(t) {
t.nonNull.int('id');
t.nonNull.string('title');
}
})
const getAllMakersSkills = extendType({
type: "Query",
definition(t) {
t.nonNull.list.nonNull.field('getAllMakersSkills', {
type: MakerSkill,
async resolve(parent, args, context) {
return []
}
})
}
})
const User = objectType({
name: 'User',
definition(t) {
@@ -312,6 +349,65 @@ const updateUserPreferences = extendType({
const MakerRoleInput = inputObjectType({
name: "MakerRoleInput",
definition(t) {
t.nonNull.int('id');
t.nonNull.field('level', { type: RoleLevelEnum })
}
})
const MakerSkillInput = inputObjectType({
name: "MakerSkillInput",
definition(t) {
t.nonNull.int('id');
}
})
const ProfileRolesInput = inputObjectType({
name: 'ProfileRolesInput',
definition(t) {
t.nonNull.list.nonNull.field('roles', {
type: MakerRoleInput,
})
t.nonNull.list.nonNull.field('skills', {
type: MakerSkillInput,
})
}
})
const updateProfileRoles = extendType({
type: 'Mutation',
definition(t) {
t.field('updateProfileRoles', {
type: 'MyProfile',
args: { data: ProfileRolesInput },
async resolve(_root, args, ctx) {
const user = await getUserByPubKey(ctx.userPubKey);
// Do some validation
if (!user)
throw new Error("You have to login");
// TODO: validate new data
// Preprocess & insert
return prisma.user.update({
where: {
id: user.id,
},
// data: removeNulls(args.data)
})
}
})
},
})
module.exports = {
// Types
@@ -324,7 +420,10 @@ module.exports = {
me,
profile,
similarMakers,
getAllMakersRoles,
getAllMakersSkills,
// Mutations
updateProfileDetails,
updateUserPreferences,
updateProfileRoles,
}