Using @defer under an array field will return multiple patches. Patches are unique combinations of label
and path
{
items {
id
...frag @defer(label: "my-label")
}
}
import { GraphQLSubscriptionConfig, requestSubscription } from 'relay-runtime'; | |
import { useRelayEnvironment } from 'react-relay/hooks'; | |
import { useEffect } from 'react'; | |
export const useSubscription = <TSubscriptionPayload extends object>( | |
config: GraphQLSubscriptionConfig<TSubscriptionPayload>, | |
) => { | |
const environment = useRelayEnvironment(); | |
useEffect(() => { |
import { useCallback } from 'react'; | |
import { matchRoutes, MatchedRoute, RouteConfig } from 'react-router-config'; | |
const prepareMatches = <Params extends { [K in keyof Params]?: string }>(matches: Array<MatchedRoute<Params>>) => { | |
return matches.map(match => { | |
const { route, match: matchData } = match; | |
const prepared = route.prepare ? route.prepare(matchData.params) : {}; | |
const Component = route.component.get(); | |
if (Component == null) { | |
route.component.load(); // eagerly load |
const arrayCompare = (a: string[], b: string[]) => { | |
if (a.length !== b.length) { | |
return false; | |
} | |
for (const item of a) { | |
if (b.indexOf(item) === -1) { | |
return false; | |
} | |
} |
import { Environment, Network, RecordSource, Store } from 'relay-runtime'; | |
import RelayPublishQueue from 'relay-runtime/lib/store/RelayPublishQueue.js'; | |
import RelayDefaultHandlerProvider from 'relay-runtime/lib/handlers/RelayDefaultHandlerProvider.js'; | |
const network = Network.create(fetchQuery); | |
const createEnvironment = (records = {}) => { | |
const source = new RecordSource(records); | |
const store = new Store(source); |
import { useState, useEffect } from 'react'; | |
import { RelayRefetchProp } from 'react-relay'; | |
const TOTAL_REFETCH_ITEMS = 1000; | |
type PageInfo = { | |
hasNextPage: boolean; | |
startCursor: string | null; | |
endCursor: string | null; | |
}; |
import idx from 'idx'; | |
import { ForwardFeature } from './mapboxTypes'; | |
export interface AddressResult { | |
id?: string | null; | |
fullAddress?: string | null; | |
shortAddress?: string | null; | |
zipcode?: string | null; | |
street?: string | null; |
Using @defer under an array field will return multiple patches. Patches are unique combinations of label
and path
{
items {
id
...frag @defer(label: "my-label")
}
}
import { useNavigationParam } from 'react-navigation-hooks'; | |
import { graphql, usePreloadedQuery } from 'react-relay/hooks'; | |
const query = graphql` | |
query TaskDetailQuery($nodeId: ID!) { | |
task: node(id: $nodeId) { | |
... on Task { | |
title | |
} | |
} |
import {useCallback, useRef, useEffect} from 'react' | |
import {useField, useFormikContext} from 'formik' | |
import update from 'immutability-helper' | |
const useFieldArray = props => { | |
const [field, meta] = useField(props) | |
const fieldArray = useRef(field.value) | |
const {setFieldValue} = useFormikContext() | |
useEffect(() => { |
import dot from 'dot-object'; | |
import { stringify } from 'query-string'; | |
import React, { useState } from 'react'; | |
import { RelayRefetchProp } from 'react-relay'; | |
import { RouteComponentProps, useHistory } from 'react-router-dom'; | |
export type PaginationProps = { | |
handleRowsPerPageChange: (quantity: number) => void; | |
totalItems: number; | |
rowsPerPage: number; |