File size: 410 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// @flow
import type { GraphQLContext } from '../../';
import { canViewThread } from '../../utils/permissions';

export default async (
  _: any,
  { id }: { id: string },
  { loaders, user }: GraphQLContext
) => {
  if (!(await canViewThread(user ? user.id : 'undefined', id, loaders))) {
    return null;
  }

  const thread = await loaders.thread.load(id);

  if (!thread) return null;

  return thread;
};