This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloError, FetchResult } from '@apollo/client'; | |
import { | |
GetCategoriesDocument, | |
useRemoveCategoryMutation, | |
CategoryPartsFragment, | |
RemoveCategoryMutation, | |
} from '../../generated/graphql'; | |
// NOTE: the rationale for using a custom hook is for the cache update, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloError, FetchResult } from '@apollo/client'; | |
import { | |
useRemoveCardMutation, | |
RemoveCardMutation, | |
GetCategoryWithCardsDocument, | |
GetCategoryWithCardsQuery, | |
} from '../../generated/graphql'; | |
import { buildPageInfo } from './__utils'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function afterIdLimitPaginatedFieldPolicy<T>() { | |
return { | |
merge(existing: T[], incoming: T[], { args, readField }): T[] { | |
... | |
}, | |
read(existing: T[], { args, readField }): T[] { | |
... | |
}, | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ApolloError, | |
FetchResult, | |
Reference, | |
ApolloCache, | |
} from '@apollo/client'; | |
import { | |
useRemoveCardMutation, | |
RemoveCardMutation, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeCategory = (id: string) => | |
removeCategoryMutation({ | |
variables: { | |
id, | |
}, | |
update: cache => { | |
cache.modify('ROOT_QUERY', { | |
categories(categories: Reference[], { readField }) { | |
return categories.filter( | |
category => id !== readField('id', category), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
overwrite: true | |
schema: "http://localhost:4000/graphql" | |
documents: src/**/*.graphql | |
generates: | |
src/generated/graphql.ts: | |
hooks: | |
afterOneFileWrite: | |
- prettier --write | |
plugins: | |
- "typescript" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
overwrite: true | |
schema: "http://localhost:4000/graphql" | |
documents: src/**/*.graphql | |
generates: | |
src/generated/graphql.ts: | |
hooks: | |
afterOneFileWrite: | |
- prettier --write | |
plugins: | |
- "typescript" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import { | |
ApolloClient, | |
ApolloProvider, | |
HttpLink, | |
InMemoryCache, | |
} from '@apollo/client'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cuckoosCallingBook = { | |
__typename: 'Book', | |
isbn: '031648637X', | |
title: "The Cuckoo's Calling", | |
author: { | |
__typename: 'Author', | |
name: 'Robert Galbraith', | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import CardParts from "CardParts.graphql"; | |
# import CategoryParts from "CategoryParts.graphql"; | |
query GetCategoryNode( | |
$id: ID! | |
$first: Int | |
$last: Int | |
$after: String | |
$before: String | |
$orderByColumn: String |