Skip to content

Commit

Permalink
Add artist field to entry (#13)
Browse files Browse the repository at this point in the history
* add artist to entry field

* add comment
  • Loading branch information
alejomendoza authored Oct 28, 2019
1 parent 9ea7362 commit 0075124
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions graphql/mutations/create-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const createEntry = {
title: {
type: new GraphQLNonNull(GraphQLString),
},
artist: {
type: new GraphQLNonNull(GraphQLString),
},
videoUrl: {
type: new GraphQLNonNull(GraphQLString),
},
Expand All @@ -44,6 +47,7 @@ const createEntry = {
imageUrl,
description,
title,
artist,
videoUrl,
id,
forSale,
Expand All @@ -55,6 +59,7 @@ const createEntry = {
imageUrl: imageUrl,
description: description,
title: title,
artist: artist,
videoUrl: videoUrl,
publishedAt: new Date().toISOString(),
publishedAtTimestamp: Math.floor(new Date().getTime() / 1000),
Expand Down
3 changes: 3 additions & 0 deletions graphql/mutations/remove-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const removeEntry = {
},
},
async resolve(_: any, { id, cloudinaryPublicId }: any, ctx: any) {
// TO DO: id and cloudinaryPublicId are the same and should be the same
// remove cloudinaryPublicId and replace it with id

const user = await getAuthenticatedUser(ctx);
let entry = await Database.models.entry.findOne({
where: { id: id },
Expand Down
6 changes: 6 additions & 0 deletions graphql/types/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ const Entry: GraphQLObjectType = new GraphQLObjectType({
return entry.price;
},
},
artist: {
type: GraphQLString,
resolve(entry: any) {
return entry.artist;
},
},
userDisplayName: {
type: GraphQLString,
async resolve(entry: any) {
Expand Down
4 changes: 4 additions & 0 deletions models/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const EntryType = {
type: Sequelize.STRING,
allowNull: false,
},
artist: {
type: Sequelize.STRING,
allowNull: false,
},
id: {
type: Sequelize.STRING,
allowNull: false,
Expand Down

0 comments on commit 0075124

Please sign in to comment.