Skip to content

Commit

Permalink
feat(preview): donne accès aux articles sans être connecté·e
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Jan 21, 2025
1 parent f450505 commit 9d2d6d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
6 changes: 3 additions & 3 deletions graphql/resolvers/articleResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ module.exports = {
* Fetch an article as the current user
*
* @param {null} _root
* @param {*} args
* @param {{ article: string }} args
* @param {{ loaders: { article }, userId, token }} context
* @returns
*/
async article(_root, args, context) {
return await getArticleByContext(args.article, context)
async article(_root, args) {
return await getArticle(args.article)
},

/**
Expand Down
9 changes: 1 addition & 8 deletions graphql/resolvers/corpusResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,13 @@ module.exports = {
*/
async corpus(_, args, context) {
const { user } = context
if (!user) {
throw new ApiError(
'UNAUTHENTICATED',
'Unable to get a list of corpus as an unauthenticated user'
)
}

if ('filter' in args) {
const filter = args.filter
if ('corpusId' in filter) {
return [await getCorpus(filter.corpusId)]
}
if ('workspaceId' in filter) {
// check that the user can access the workspace
await Workspace.getWorkspaceById(filter.workspaceId, user)
return Corpus.find({ workspace: filter.workspaceId })
.populate([{ path: 'creator' }])
.sort([['updatedAt', -1]])
Expand Down

0 comments on commit 9d2d6d4

Please sign in to comment.