diff --git a/src/cache/cache.ts b/src/cache/cache.ts index 8c06e3b..f3f6664 100644 --- a/src/cache/cache.ts +++ b/src/cache/cache.ts @@ -165,19 +165,25 @@ export class ClientCache { fieldNameWithArguments, value, path, + jsonPath, ancestors, variables, + queryVariables, rootTypename, selectedKeys, + documentNode, }: { originalFieldName: string; fieldNameWithArguments: symbol | string; value: unknown; path: PropertyKey[]; + jsonPath: PropertyKey[]; ancestors: unknown[]; variables: Record; + queryVariables: Record; rootTypename: string; selectedKeys: Set; + documentNode: DocumentNode; }) { const ancestorsCopy = ancestors.concat(); const pathCopy = path.concat(); @@ -207,6 +213,10 @@ export class ClientCache { ), ]; value.__connectionArguments = variables; + // used to retrieve up to date data from pagination hook + value.__connectionQueryArguments = queryVariables; + value.__connectionDocumentNode = documentNode; + value.__connectionJsonPath = [...jsonPath, originalFieldName]; } value[REQUESTED_KEYS] = selectedKeys; } diff --git a/src/cache/write.ts b/src/cache/write.ts index 1f473ef..4c1281f 100644 --- a/src/cache/write.ts +++ b/src/cache/write.ts @@ -24,6 +24,7 @@ export const writeOperationToCache = ( selections: SelectionSetNode, data: unknown[], path: PropertyKey[] = [], + jsonPath: PropertyKey[] = [], rootTypename: string, ) => { selections.selections.forEach((selection) => { @@ -47,10 +48,13 @@ export const writeOperationToCache = ( fieldNameWithArguments, value: fieldValue, path, + jsonPath, ancestors: data, variables: fieldArguments, + queryVariables: variables, rootTypename, selectedKeys, + documentNode: document, }); const nextValue = Array(fieldValue.length); @@ -60,10 +64,13 @@ export const writeOperationToCache = ( fieldNameWithArguments, value: nextValue, path: [...path, fieldNameWithArguments], + jsonPath: [...jsonPath, originalFieldName], ancestors: [...data, fieldValue], variables: fieldArguments, + queryVariables: variables, rootTypename, selectedKeys, + documentNode: document, }); fieldValue.forEach((item: unknown, index: number) => { @@ -74,10 +81,13 @@ export const writeOperationToCache = ( fieldNameWithArguments: index.toString(), value, path: [...path, fieldNameWithArguments], + jsonPath: [...jsonPath, originalFieldName], ancestors: [...data, fieldValue], variables: fieldArguments, + queryVariables: variables, rootTypename, selectedKeys, + documentNode: document, }); if (isRecord(item)) { @@ -85,6 +95,7 @@ export const writeOperationToCache = ( fieldNode.selectionSet!, [...data, fieldValue, item], [...path, fieldNameWithArguments, index.toString()], + [...jsonPath, originalFieldName, index.toString()], rootTypename, ); } @@ -97,10 +108,13 @@ export const writeOperationToCache = ( fieldNameWithArguments, value, path, + jsonPath, ancestors: data, variables: fieldArguments, + queryVariables: variables, rootTypename, selectedKeys, + documentNode: document, }); if (isRecord(fieldValue) && fieldNode.selectionSet != undefined) { @@ -108,6 +122,7 @@ export const writeOperationToCache = ( fieldNode.selectionSet, [...data, fieldValue], [...path, fieldNameWithArguments], + [...jsonPath, originalFieldName], rootTypename, ); } @@ -119,16 +134,25 @@ export const writeOperationToCache = ( fieldNameWithArguments, value: fieldValue, path, + jsonPath, ancestors: data, variables: fieldArguments, + queryVariables: variables, rootTypename, selectedKeys, + documentNode: document, }); } } }) .with({ kind: Kind.INLINE_FRAGMENT }, (inlineFragmentNode) => { - traverse(inlineFragmentNode.selectionSet, data, path, rootTypename); + traverse( + inlineFragmentNode.selectionSet, + data, + path, + jsonPath, + rootTypename, + ); }) .with({ kind: Kind.FRAGMENT_SPREAD }, () => { // ignore, those are stripped @@ -155,7 +179,7 @@ export const writeOperationToCache = ( : response, getSelectedKeys(definition, variables), ); - traverse(definition.selectionSet, [response], [], rootTypename); + traverse(definition.selectionSet, [response], [], [], rootTypename); } }); diff --git a/src/react/usePagination.ts b/src/react/usePagination.ts index 73c032d..93dbc24 100644 --- a/src/react/usePagination.ts +++ b/src/react/usePagination.ts @@ -1,7 +1,10 @@ -import { useRef } from "react"; +import { DocumentNode } from "@0no-co/graphql.web"; +import { Option, Result } from "@swan-io/boxed"; +import { useCallback, useContext, useRef, useSyncExternalStore } from "react"; import { match } from "ts-pattern"; import { Connection } from "../types"; -import { isRecord } from "../utils"; +import { deepEqual, isRecord, serializeVariables } from "../utils"; +import { ClientContext } from "./ClientContext"; type mode = "before" | "after"; @@ -81,13 +84,86 @@ const mergeConnection = >( const createPaginationHook = (direction: mode) => { return >(connection: T): T => { - const connectionRef = useRef(connection); - connectionRef.current = mergeConnection( - connectionRef.current, - connection, - direction, + const client = useContext(ClientContext); + const connectionArgumentsRef = useRef<[string, Record][]>( + [], ); - return connectionRef.current; + + if (connection != null && "__connectionQueryArguments" in connection) { + const arg = connection.__connectionQueryArguments as Record< + string, + unknown + >; + const serializedArg = serializeVariables(arg); + if ( + !connectionArgumentsRef.current.find( + ([serialized]) => serializedArg === serialized, + ) + ) { + connectionArgumentsRef.current = [ + ...connectionArgumentsRef.current, + [serializedArg, arg], + ]; + } + } + + const jsonPath = useRef( + connection != null && "__connectionJsonPath" in connection + ? (connection.__connectionJsonPath as string[]) + : [], + ); + + const documentNode = + connection != null && "__connectionDocumentNode" in connection + ? (connection.__connectionDocumentNode as DocumentNode) + : undefined; + + const lastReturnedValueRef = useRef>(Option.None()); + + // Get fresh data from cache + const getSnapshot = useCallback(() => { + if (documentNode == null) { + return Option.None(); + } + const value = Option.all( + connectionArgumentsRef.current.map(([, args]) => + client.readFromCache(documentNode, args, {}), + ), + ) + .map(Result.all) + .flatMap((x) => x.toOption()) + .map((queries) => + queries.map((query) => + jsonPath.current.reduce( + (acc, key) => + acc != null && typeof acc === "object" && key in acc + ? // @ts-expect-error indexable + acc[key] + : null, + query, + ), + ), + ) as Option; + if (!deepEqual(value, lastReturnedValueRef.current)) { + lastReturnedValueRef.current = value; + return value; + } else { + return lastReturnedValueRef.current; + } + }, [client, documentNode]); + + const data = useSyncExternalStore( + (func) => client.subscribe(func), + getSnapshot, + ) as Option; + + return data + .map(([first, ...rest]) => + rest.reduce((acc, item) => { + return mergeConnection(acc, item, direction); + }, first), + ) + .getOr(connection) as T; }; }; diff --git a/test/__snapshots__/cache.test.ts.snap b/test/__snapshots__/cache.test.ts.snap index bd30823..b9f95b3 100644 --- a/test/__snapshots__/cache.test.ts.snap +++ b/test/__snapshots__/cache.test.ts.snap @@ -23,6 +23,542 @@ Map { }, ], ], + "__connectionDocumentNode": { + "definitions": [ + { + "directives": undefined, + "kind": "OperationDefinition", + "name": { + "kind": "Name", + "value": "App", + }, + "operation": "query", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMembership", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "firstName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "identificationLevels", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "expert", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "PVID", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "QES", + }, + "selectionSet": undefined, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "IdentificationLevels", + }, + }, + }, + ], + }, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "User", + }, + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "first", + }, + "value": { + "kind": "IntValue", + "value": "2", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMemberships", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "edges", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "node", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "account", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "name", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": { + "kind": "Name", + "value": "membershipUser", + }, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "block": false, + "kind": "StringValue", + "value": "e8d38e87-9862-47ef-b749-212ed566b955", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocumentCollection", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocuments", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "createdAt", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + "variableDefinitions": [ + { + "defaultValue": undefined, + "directives": undefined, + "kind": "VariableDefinition", + "type": { + "kind": "NonNullType", + "type": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "ID", + }, + }, + }, + "variable": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + }, + ], + "kind": "Document", + }, + "__connectionJsonPath": [ + "accountMemberships", + ], + "__connectionQueryArguments": { + "id": "1", + }, Symbol(__requestedKeys): Set { Symbol(__typename), Symbol(edges), @@ -161,6 +697,542 @@ Map { }, ], ], + "__connectionDocumentNode": { + "definitions": [ + { + "directives": undefined, + "kind": "OperationDefinition", + "name": { + "kind": "Name", + "value": "App", + }, + "operation": "query", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMembership", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "firstName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "identificationLevels", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "expert", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "PVID", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "QES", + }, + "selectionSet": undefined, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "IdentificationLevels", + }, + }, + }, + ], + }, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "User", + }, + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "first", + }, + "value": { + "kind": "IntValue", + "value": "2", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMemberships", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "edges", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "node", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "account", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "name", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": { + "kind": "Name", + "value": "membershipUser", + }, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "block": false, + "kind": "StringValue", + "value": "e8d38e87-9862-47ef-b749-212ed566b955", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocumentCollection", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocuments", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "createdAt", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + "variableDefinitions": [ + { + "defaultValue": undefined, + "directives": undefined, + "kind": "VariableDefinition", + "type": { + "kind": "NonNullType", + "type": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "ID", + }, + }, + }, + "variable": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + }, + ], + "kind": "Document", + }, + "__connectionJsonPath": [ + "accountMemberships", + ], + "__connectionQueryArguments": { + "id": "1", + }, Symbol(__requestedKeys): Set { Symbol(__typename), Symbol(edges), @@ -333,6 +1405,542 @@ Map { }, ], ], + "__connectionDocumentNode": { + "definitions": [ + { + "directives": undefined, + "kind": "OperationDefinition", + "name": { + "kind": "Name", + "value": "App", + }, + "operation": "query", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMembership", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "firstName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "identificationLevels", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "expert", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "PVID", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "QES", + }, + "selectionSet": undefined, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "IdentificationLevels", + }, + }, + }, + ], + }, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "User", + }, + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "first", + }, + "value": { + "kind": "IntValue", + "value": "2", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMemberships", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "edges", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "node", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "account", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "name", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": { + "kind": "Name", + "value": "membershipUser", + }, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "block": false, + "kind": "StringValue", + "value": "e8d38e87-9862-47ef-b749-212ed566b955", + }, + }, + ], + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocumentCollection", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocuments", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "createdAt", + }, + "selectionSet": undefined, + }, + ], + }, + }, + { + "alias": undefined, + "arguments": undefined, + "directives": undefined, + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + "selectionSet": undefined, + }, + ], + }, + }, + ], + }, + "variableDefinitions": [ + { + "defaultValue": undefined, + "directives": undefined, + "kind": "VariableDefinition", + "type": { + "kind": "NonNullType", + "type": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "ID", + }, + }, + }, + "variable": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + }, + ], + "kind": "Document", + }, + "__connectionJsonPath": [ + "accountMemberships", + ], + "__connectionQueryArguments": { + "id": "1", + }, Symbol(__requestedKeys): Set { Symbol(__typename), Symbol(edges), @@ -754,6 +2362,445 @@ exports[`Write & read in cache 7`] = ` }, ], ], + "__connectionDocumentNode": { + "definitions": [ + { + "kind": "OperationDefinition", + "name": { + "kind": "Name", + "value": "App", + }, + "operation": "query", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMembership", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "firstName", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "identificationLevels", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "InlineFragment", + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "expert", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "PVID", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "QES", + }, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "IdentificationLevels", + }, + }, + }, + ], + }, + }, + ], + }, + "typeCondition": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "User", + }, + }, + }, + ], + }, + }, + ], + }, + }, + { + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "first", + }, + "value": { + "kind": "IntValue", + "value": "2", + }, + }, + ], + "kind": "Field", + "name": { + "kind": "Name", + "value": "accountMemberships", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "edges", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "node", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "account", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "name", + }, + }, + ], + }, + }, + { + "alias": { + "kind": "Name", + "value": "membershipUser", + }, + "kind": "Field", + "name": { + "kind": "Name", + "value": "user", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "lastName", + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + { + "arguments": [ + { + "kind": "Argument", + "name": { + "kind": "Name", + "value": "id", + }, + "value": { + "block": false, + "kind": "StringValue", + "value": "e8d38e87-9862-47ef-b749-212ed566b955", + }, + }, + ], + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocumentCollection", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "supportingDocuments", + }, + "selectionSet": { + "kind": "SelectionSet", + "selections": [ + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "__typename", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "createdAt", + }, + }, + ], + }, + }, + { + "kind": "Field", + "name": { + "kind": "Name", + "value": "id", + }, + }, + ], + }, + }, + ], + }, + "variableDefinitions": [ + { + "kind": "VariableDefinition", + "type": { + "kind": "NonNullType", + "type": { + "kind": "NamedType", + "name": { + "kind": "Name", + "value": "ID", + }, + }, + }, + "variable": { + "kind": "Variable", + "name": { + "kind": "Name", + "value": "id", + }, + }, + }, + ], + }, + ], + "kind": "Document", + }, + "__connectionJsonPath": [ + "accountMemberships", + ], + "__connectionQueryArguments": { + "id": "1", + }, "__typename": "AccountMembershipConnection", "edges": [ {