latest
Direction to add to in a list. Either "head" or "tail"
Type:
("head"
| "tail"
)
Returns a function that will use Apollo's DataProxy to update a Query by adding an edge to a list of edges.
(DocumentNode)
GraphQL query constructed with
graphql-tag
(string)
Mutation name
(AddTo)
Whether to add the new edge to the beginning or end of the list
Function
:
A function that it's passed to Apollo's update function.
Returns a function that will use Apollo's DataProxy to update a Fragment by adding an edge to a list of edges.
(DocumentNode)
GraphQL fragment constructed with
graphql-tag
(string)
Mutation name
(string)
The root ID for this fragment
(string)
Whether to add the new edge to the beginning or end of the list
((DataProxyReadFragmentOptions | DataProxyWriteFragmentOptions)
= {}
)
Function
:
A function that it's passed to Apollo's update function.
{
// ...
update: addEdgeToFragment(
Favorites.fragments.favorites,
'toggleFavorite',
['favorites'],
userId,
'head',
{
fragmentName: 'Favorites',
}
),
}
Remove an edge from a list
any
:
Remove edge from a list in Fragment
(DocumentNode)
(string)
(string)
((DataProxyReadFragmentOptions | DataProxyWriteFragmentOptions))
Function
:
Replaces an edge in a Fragment
any
:
Replaces an edge in a list
any
:
Modified version of cursorForObjectInConnection which uses primary ID as well
any
:
Return a content type from a filename, uses mime
.
(string)
string
:
ContentType
Convert a content-type to a valid GraphQL scbema type
({contentType: string})
string
:
Image, Video, Audio if content type matches, GenericFile otherwise
Returns an optimistic response for a File for instant display
any
:
Return values for obj
omitting id
and __typename
.
Returns true whether the arguments is nil or and empty string
Type: Function
Returns whether a prop isEmpty
Type: Function
Returns whether the given Ramda path isEmpty
Type: Function
Returns true is a given string is an UUID.
UUIDs are commonly used to mark optimistic responses.
Add edge to a mutation result
Shape: { edge: { node: result } }
(any)
{edge: {node: any}}
:
Add both edge and cursor to a mutation result
Cursor is calculated via cursorForObjectInConnection
.
Type: Function
Generate an optimistic response
Type: Function
(String)
The name of the mutation that was run
(String)
The name of the payload in the response object
(Object)
Partial response for the object that's to be returned by the server
Function
:
function that takes variables and can be passed to Apollo's
optimisticResponse
Map edges to prop
Convert edges structure to an array of objects (nodes).
Type: Function
(String)
Name of the prop to map edges to
Function
:
Function that takes a data object. mapEdgesToProp is curried so you can pass it directly.
Flattens edges recursively
Replaces edges structures with arrays of nodes.
Type: Function
(Connection)