Download spectrum/api/queries/community/channelConnection.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 686 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/community/channelConnection.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/community/channelConnection.js
-
curl -L -o channelConnection.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/community/channelConnection.js
686 Bytes
| // @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, | |
| })) | |
| ), | |
| }; | |
| }; | |