-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reviews): display review history
- Loading branch information
Showing
22 changed files
with
445 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { assertNever } from "@argos/util/assertNever"; | ||
import { invariant } from "@argos/util/invariant"; | ||
import gqlTag from "graphql-tag"; | ||
|
||
import { | ||
IBuildReviewState, | ||
type IResolvers, | ||
} from "../__generated__/resolver-types.js"; | ||
|
||
const { gql } = gqlTag; | ||
|
||
export const typeDefs = gql` | ||
enum BuildReviewState { | ||
APPROVED | ||
REJECTED | ||
PENDING | ||
} | ||
type BuildReview implements Node { | ||
id: ID! | ||
date: DateTime! | ||
user: User | ||
state: BuildReviewState! | ||
} | ||
`; | ||
|
||
export const resolvers: IResolvers = { | ||
BuildReview: { | ||
date: (review) => { | ||
return review.createdAt; | ||
}, | ||
state: (review) => { | ||
switch (review.state) { | ||
case "approved": | ||
return IBuildReviewState.Approved; | ||
case "rejected": | ||
return IBuildReviewState.Rejected; | ||
case "pending": | ||
return IBuildReviewState.Pending; | ||
default: | ||
assertNever(review.state); | ||
} | ||
}, | ||
user: async (review, _, ctx) => { | ||
if (!review.userId) { | ||
return null; | ||
} | ||
const account = await ctx.loaders.AccountFromRelation.load({ | ||
userId: review.userId, | ||
}); | ||
invariant(account, "Account not found"); | ||
return account; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.