File size: 686 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
// @flow
import type { GraphQLContext } from '../../';
import type { DBCommunity } from 'shared/types';
import { getChannelsByCommunity } from '../../models/channel';
import { canViewCommunity } from '../../utils/permissions';
export default async ({ id }: DBCommunity, _: any, ctx: GraphQLContext) => {
const { user, loaders } = ctx;
if (!(await canViewCommunity(user, id, loaders))) {
return {
pageInfo: {
hasNextPage: false,
},
edges: [],
};
}
return {
pageInfo: {
hasNextPage: false,
},
edges: getChannelsByCommunity(id).then(channels =>
channels.map(channel => ({
node: channel,
}))
),
};
};
|