-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGifQuery.tsx
39 lines (32 loc) · 969 Bytes
/
GifQuery.tsx
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
31
32
33
34
35
36
37
38
39
import React, { ReactNode, FunctionComponent } from 'react';
import { Query, QueryResult, QueryProps } from 'react-apollo';
import {
gif as GifQueryData,
gifVariables as GifQueryVariables,
gif_gif as Gif,
} from './gif';
import gifQuery from './gif.gql';
class BaseGifQuery extends Query<GifQueryData, GifQueryVariables> {}
interface GifQueryProps {
children: (
result: Omit<QueryResult<GifQueryData>, 'data'> & {
gif: Gif | null;
},
) => ReactNode;
variables: GifQueryVariables;
}
const GifQuery: FunctionComponent<
Omit<QueryProps<GifQueryData>, 'query' | 'children' | 'variables'> &
GifQueryProps
> = ({ children, ...otherProps }) => (
<BaseGifQuery {...otherProps} query={gifQuery}>
{({ data, ...otherArgs }) =>
children({
...otherArgs,
gif: data && data.gif ? data.gif : null,
})
}
</BaseGifQuery>
);
export default GifQuery;
export { Gif, GifQueryData, GifQueryVariables, GifQuery };