-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5956 from apollographql/mutate-update-no-data-proxy
Mutate update function DataProxy/ApolloCache changes
- Loading branch information
Showing
13 changed files
with
108 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { SelectionSetNode } from 'graphql'; | ||
|
||
import { | ||
isReference, | ||
StoreValue, | ||
StoreObject, | ||
Reference | ||
} from '../../../utilities/graphql/storeUtils'; | ||
import { FragmentMap } from '../../../utilities/graphql/fragments'; | ||
|
||
// The Readonly<T> type only really works for object types, since it marks | ||
// all of the object's properties as readonly, but there are many cases when | ||
// a generic type parameter like TExisting might be a string or some other | ||
// primitive type, in which case we need to avoid wrapping it with Readonly. | ||
// SafeReadonly<string> collapses to just string, which makes string | ||
// assignable to SafeReadonly<any>, whereas string is not assignable to | ||
// Readonly<any>, somewhat surprisingly. | ||
export type SafeReadonly<T> = T extends object ? Readonly<T> : T; | ||
|
||
export type Modifier<T> = (value: T, details: { | ||
DELETE: any; | ||
fieldName: string; | ||
storeFieldName: string; | ||
isReference: typeof isReference; | ||
toReference( | ||
object: StoreObject, | ||
selectionSet?: SelectionSetNode, | ||
fragmentMap?: FragmentMap, | ||
): Reference; | ||
readField<V = StoreValue>( | ||
fieldName: string, | ||
objOrRef?: StoreObject | Reference, | ||
): SafeReadonly<V>; | ||
}) => T; | ||
|
||
export type Modifiers = { | ||
[fieldName: string]: Modifier<any>; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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