Download spectrum/shared/graphql/apollo-client-options.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/graphql/apollo-client-options.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/shared/graphql/apollo-client-options.js
-
curl -L -o apollo-client-options.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/graphql/apollo-client-options.js
1.87 kB
| var apollo = require('apollo-utilities'), | |
| toIdValue = apollo.toIdValue; | |
| function dataIdFromObject(result) { | |
| if (result.__typename) { | |
| // Custom Community cache key based on slug | |
| if (result.__typename === 'Community' && !!result.slug) { | |
| return result.__typename + ':' + result.slug; | |
| } | |
| // Custom Channel cache key based on slug and community slug | |
| if ( | |
| result.__typename === 'Channel' && | |
| !!result.slug && | |
| !!result.community && | |
| !!result.community.slug | |
| ) { | |
| return ( | |
| result.__typename + ':' + result.community.slug + ':' + result.slug | |
| ); | |
| } | |
| // This was copied from the default dataIdFromObject | |
| if (result.id !== undefined) { | |
| return result.__typename + ':' + result.id; | |
| } | |
| if (result._id !== undefined) { | |
| return result.__typename + ':' + result._id; | |
| } | |
| } | |
| return null; | |
| } | |
| var getSharedApolloClientOptions = function getSharedApolloClientOptions() { | |
| return { | |
| queryDeduplication: true, | |
| dataIdFromObject: dataIdFromObject, | |
| cacheRedirects: { | |
| Query: { | |
| thread: function thread(_, _ref) { | |
| var id = _ref.id; | |
| return toIdValue(dataIdFromObject({ __typename: 'Thread', id: id })); | |
| }, | |
| community: function community(_, _ref2) { | |
| var slug = _ref2.slug; | |
| return toIdValue( | |
| dataIdFromObject({ __typename: 'Community', slug: slug }) | |
| ); | |
| }, | |
| channel: function channel(_, _ref3) { | |
| var channelSlug = _ref3.channelSlug, | |
| communitySlug = _ref3.communitySlug; | |
| return toIdValue( | |
| dataIdFromObject({ | |
| __typename: 'Channel', | |
| slug: channelSlug, | |
| community: { slug: communitySlug }, | |
| }) | |
| ); | |
| }, | |
| }, | |
| }, | |
| }; | |
| }; | |
| module.exports = getSharedApolloClientOptions; | |