Direction to add to in a list. Either "head" or "tail"

AddTo

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.

addEdge
Parameters
query (DocumentNode) GraphQL query constructed with graphql-tag
operationName (string) Mutation name
edgePath (Array<string>) An array to a path to the list of edges
addTo (AddTo) Whether to add the new edge to the beginning or end of the list
Returns
Function: A function that it's passed to Apollo's update function.

addEdgeToFragment

src/apollo.js

Returns a function that will use Apollo's DataProxy to update a Fragment by adding an edge to a list of edges.

addEdgeToFragment
Parameters
fragment (DocumentNode) GraphQL fragment constructed with graphql-tag
operationName (string) Mutation name
edgePath (Array<string>) An array to a path to the list of edges
rootId (string) The root ID for this fragment
addTo (string) Whether to add the new edge to the beginning or end of the list
fragmentOptions ((DataProxyReadFragmentOptions | DataProxyWriteFragmentOptions) = {})
Returns
Function: A function that it's passed to Apollo's update function.
Example
{
  // ...
  update: addEdgeToFragment(
     Favorites.fragments.favorites,
    'toggleFavorite',
    ['favorites'],
    userId,
    'head',
    {
      fragmentName: 'Favorites',
    }
  ),
}

removeEdge

src/apollo.js

Remove an edge from a list

removeEdge
Parameters
edgePath (Array<string>)
edgeId (string)
data (Object)
payload (Object)
Returns
any:

removeEdgeFromFragment

src/apollo.js

Remove edge from a list in Fragment

removeEdgeFromFragment
Parameters
fragment (DocumentNode)
edgeId (string)
rootId (string)
edgePath (Array<string>)
fragmentOptions ((DataProxyReadFragmentOptions | DataProxyWriteFragmentOptions))
Returns
Function:

replaceEdgeInFragment

src/apollo.js

Replaces an edge in a Fragment

replaceEdgeInFragment
Parameters
edge (Object)
fragment (DocumentNode)
rootId (string)
edgePath (Array<string>)
Returns
any:

Replaces an edge in a list

replaceEdge
Parameters
data (any)
edgePath (Array<string>)
edge (Object)
Returns
any:

cursorForObjectInConnection

src/connection.js

Modified version of cursorForObjectInConnection which uses primary ID as well

cursorForObjectInConnection
Parameters
connection (Array<Object>)
obj (Object)
Returns
any:

getContentTypeFromFilename

src/files.js

Return a content type from a filename, uses mime.

getContentTypeFromFilename
Parameters
filename (string)
Returns
string: ContentType

getTypenameForFile

src/files.js

Convert a content-type to a valid GraphQL scbema type

getTypenameForFile
Parameters
file ({contentType: string})
Returns
string: Image, Video, Audio if content type matches, GenericFile otherwise

optimisticFileResponse

src/files.js

Returns an optimistic response for a File for instant display

optimisticFileResponse
Parameters
file ({contentType: string, name: string, url: string})
Returns
any:

formValues

src/forms.js

Return values for obj omitting id and __typename.

formValues

Returns true whether the arguments is nil or and empty string

isEmpty

Type: Function

isEmptyProp

src/isEmpty.js

Returns whether a prop isEmpty

isEmptyProp

Type: Function

isEmptyPath

src/isEmpty.js

Returns whether the given Ramda path isEmpty

isEmptyPath

Type: Function

Returns true is a given string is an UUID.

UUIDs are commonly used to mark optimistic responses.

isOptimistic

Type: function (string): boolean

addEdgeToMutationResult

src/mutations.js

Add edge to a mutation result

Shape: { edge: { node: result } }

addEdgeToMutationResult
Parameters
response (any)
Returns
{edge: {node: any}}:

addEdgeAndCursorToMutationResult

src/mutations.js

Add both edge and cursor to a mutation result Cursor is calculated via cursorForObjectInConnection.

addEdgeAndCursorToMutationResult

Type: Function

Parameters
connectionGetter (Function) Function that returns a promise of a Connection of all records
obj (Object) The current object

optimisticResponse

src/mutations.js

Generate an optimistic response

optimisticResponse

Type: Function

Parameters
operationName (String) The name of the mutation that was run
payloadName (String) The name of the payload in the response object
response (Object) Partial response for the object that's to be returned by the server
Returns
Function: function that takes variables and can be passed to Apollo's optimisticResponse

mapEdgesToProp

src/props.js

Map edges to prop

Convert edges structure to an array of objects (nodes).

mapEdgesToProp

Type: Function

Parameters
edgePath (String) A dot-path to the edges (e.g viewer.user.favorites , edges suffix is optional)
propName (String) Name of the prop to map edges to
Returns
Function: Function that takes a data object. mapEdgesToProp is curried so you can pass it directly.

flattenEdges

src/props.js

Flattens edges recursively

Replaces edges structures with arrays of nodes.

flattenEdges

Type: Function

Parameters
connection (Connection)