import type { OperationVariables, TypedDocumentNode } from '@apollo/client' import { serverCacheKey } from 'rntwsc/cache/key' import { hydrationKey } from 'rntwsc/hydration/config' import type { StrMap } from 'rntwsc/libs/utility-types' export const sck = serverCacheKey('rntwsc/graphql', ['fetch'] as const) export type UseApollo = { url: string query: TypedDocumentNode variables?: OperationVariables headers?: StrMap } export const hk = hydrationKey>('graphql') export type GraphQLResponse = { data?: T errors?: unknown[] } export const normalizeGraphQLResponse = (d: any) => { if (!d) { return } return { data: d.data ?? undefined, errors: d.errors ?? undefined, } }