Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Seanaye/feat/subscription cache deletes (#5262)

Sean Aye2c913c970c40
diff --git a/apps/web/package.json b/apps/web/package.json
index ada25c0e8a..48739b0de0 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -107,6 +107,7 @@
"email-validator": "^2.0.4",
"emojibase-data": "^17.0.0",
"emojilib": "^4.0.2",
+ "graphql-ws": "^6.1.0",
"katex": "^0.16.22",
"lexical": "0.45.0",
"libheif-js": "^1.19.8",
diff --git a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts
index eb1e8b6009..d5b05ce4db 100644
--- a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts
+++ b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts
@@ -9,7 +9,14 @@ import {
stringifyDocument,
} from '@urql/core';
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { makeSubject, map, pipe, type Source, subscribe } from 'wonka';
+import {
+ makeSubject,
+ map,
+ mergeMap,
+ pipe,
+ type Source,
+ subscribe,
+} from 'wonka';
import type { CacheHost } from '../host/types';
import type {
ClaimedMutation,
@@ -32,6 +39,25 @@ const QUERY = gql`
}
`;
+const SUBSCRIPTION = gql`
+ subscription SoupUpdates {
+ soupUpdates {
+ __typename
+ ... on SoupUpdated {
+ item {
+ __typename
+ id
+ displayName
+ }
+ }
+ ... on GraphqlCacheDeletion {
+ graphqlTypeName
+ entityId
+ }
+ }
+ }
+`;
+
const MUTATION = gql`
mutation SetEntityProperty($input: SetEntityPropertyInput!) {
setEntityProperty(input: $input) {
@@ -89,6 +115,7 @@ type FakeHost = CacheHost & {
defers: Array<{ transactionId: string; error: string }>;
claims: string[];
invalidations: string[][];
+ cacheActions: Array<{ kind: 'write' | 'delete'; value: unknown }>;
teardowns: number[];
scriptRead: (result: ReadResult) => void;
seedQueued: (args: Parameters<CacheHost['beginOptimisticWrite']>[0]) => void;
@@ -115,6 +142,7 @@ function makeFakeHost(): FakeHost {
defers: [],
claims: [],
invalidations: [],
+ cacheActions: [],
teardowns: [],
scriptRead: (r) => {
readResult = r;
@@ -147,6 +175,7 @@ function makeFakeHost(): FakeHost {
data: args.data,
identity: args.identity,
});
+ host.cacheActions.push({ kind: 'write', value: args.data });
return { changed: [], affectedOps: [], reset: false };
},
async beginOptimisticWrite(args): Promise<OptimisticWriteResult> {
@@ -224,6 +253,7 @@ function makeFakeHost(): FakeHost {
},
async deleteRecords(keys) {
host.invalidations.push(keys);
+ host.cacheActions.push({ kind: 'delete', value: keys });
return [];
},
async teardown(opKey) {
@@ -260,6 +290,18 @@ function makeOp(
);
}
+function makeSubscriptionOp(key: number): Operation {
+ return makeOperation(
+ 'subscription',
+ { key, query: SUBSCRIPTION, variables: {} },
+ {
+ requestPolicy: 'cache-first',
+ url: 'http://test',
+ suspense: false,
+ } as never
+ );
+}
+
function teardownOf(op: Operation): Operation {
return makeOperation('teardown', op, op.context);
}
@@ -379,6 +421,221 @@ describe('normalizedCacheExchange', () => {
host = makeFakeHost();
});
+ it('normalizes ordinary buffered subscription data without inspecting event types', async () => {
+ const patches = ['document-1', 'document-2'].map((id) => ({
+ __typename: 'SoupUpdated',
+ item: {
+ __typename: 'GraphqlSoupDocument',
+ id,
+ displayName: `Updated ${id}`,
+ },
+ }));
+ const data = { soupUpdates: patches };
+ const { ops, results } = harness(host, (op) =>
+ op.kind === 'subscription' ? { data } : {}
+ );
+
+ ops.next(makeSubscriptionOp(21));
+ await tick();
+
+ expect(host.writes).toHaveLength(1);
+ expect(host.writes[0]?.data).toBe(data);
+ expect(results).toHaveLength(1);
+ expect(results[0]?.data).toBe(data);
+ });
+
+ it('deletes the exact normalized key from subscription patches', async () => {
+ const data = {
+ soupUpdates: [
+ {
+ __typename: 'GraphqlCacheDeletion',
+ graphqlTypeName: 'GraphqlSoupDocument',
+ entityId: 'document-1',
+ },
+ ],
+ };
+ const { ops, results } = harness(host, (op) =>
+ op.kind === 'subscription' ? { data } : {}
+ );
+
+ ops.next(makeSubscriptionOp(22));
+ await tick();
+
+ expect(host.invalidations).toEqual([['GraphqlSoupDocument:document-1']]);
+ expect(host.writes).toHaveLength(0);
+ expect(results[0]?.data).toBe(data);
+ });
+
+ it('applies buffered mixed patches in order', async () => {
+ const deleteDocument = (id: string) => ({
+ __typename: 'GraphqlCacheDeletion',
+ graphqlTypeName: 'GraphqlSoupDocument',
+ entityId: id,
+ });
+ const updateDocument = (id: string) => ({
+ __typename: 'SoupUpdated',
+ item: {
+ __typename: 'GraphqlSoupDocument',
+ id,
+ displayName: `Document ${id}`,
+ },
+ });
+ const patches = [
+ deleteDocument('delete-then-update'),
+ updateDocument('delete-then-update'),
+ updateDocument('update-then-delete'),
+ deleteDocument('update-then-delete'),
+ ];
+ const { ops } = harness(host, (op) =>
+ op.kind === 'subscription' ? { data: { soupUpdates: patches } } : {}
+ );
+
+ ops.next(makeSubscriptionOp(23));
+ await tick();
+
+ expect(host.cacheActions).toEqual([
+ {
+ kind: 'delete',
+ value: ['GraphqlSoupDocument:delete-then-update'],
+ },
+ {
+ kind: 'write',
+ value: { soupUpdates: [patches[1]] },
+ },
+ {
+ kind: 'write',
+ value: { soupUpdates: [patches[2]] },
+ },
+ {
+ kind: 'delete',
+ value: ['GraphqlSoupDocument:update-then-delete'],
+ },
+ ]);
+ });
+
+ it('serializes cache effects across separate subscription emissions', async () => {
+ const operation = makeSubscriptionOp(24);
+ const networkResults = makeSubject<OperationResult>();
+ let cacheContainsDocument = false;
+ let markWriteStarted!: () => void;
+ let releaseWrite!: () => void;
+ const writeStarted = new Promise<void>((resolve) => {
+ markWriteStarted = resolve;
+ });
+ const writeCanFinish = new Promise<void>((resolve) => {
+ releaseWrite = resolve;
+ });
+ vi.spyOn(host, 'writeQuery').mockImplementation(async () => {
+ markWriteStarted();
+ await writeCanFinish;
+ cacheContainsDocument = true;
+ return { changed: [], affectedOps: [], reset: false };
+ });
+ vi.spyOn(host, 'deleteRecords').mockImplementation(async () => {
+ cacheContainsDocument = false;
+ return [];
+ });
+
+ const ops = makeSubject<Operation>();
+ const results: OperationResult[] = [];
+ const exchangeIo = normalizedCacheExchange(host)({
+ forward: (ops$) =>
+ pipe(
+ ops$,
+ mergeMap(() => networkResults.source)
+ ),
+ client: {
+ reexecuteOperation: vi.fn(),
+ mutation: vi.fn(),
+ } as never,
+ dispatchDebug: () => undefined,
+ });
+ pipe(
+ exchangeIo(ops.source),
+ subscribe((result) => results.push(result))
+ );
+
+ ops.next(operation);
+ networkResults.next({
+ operation,
+ data: {
+ soupUpdates: [
+ {
+ __typename: 'SoupUpdated',
+ item: {
+ __typename: 'GraphqlSoupDocument',
+ id: 'document-1',
+ displayName: 'Updated document',
+ },
+ },
+ ],
+ },
+ stale: false,
+ hasNext: true,
+ });
+ await writeStarted;
+ networkResults.next({
+ operation,
+ data: {
+ soupUpdates: [
+ {
+ __typename: 'GraphqlCacheDeletion',
+ graphqlTypeName: 'GraphqlSoupDocument',
+ entityId: 'document-1',
+ },
+ ],
+ },
+ stale: false,
+ hasNext: true,
+ });
+
+ await tick();
+ expect(host.deleteRecords).not.toHaveBeenCalled();
+ releaseWrite();
+ await vi.waitFor(() => expect(results).toHaveLength(2));
+
+ expect(host.deleteRecords).toHaveBeenCalledWith([
+ 'GraphqlSoupDocument:document-1',
+ ]);
+ expect(cacheContainsDocument).toBe(false);
+ });
+
+ it('reports cache failures without dropping subscription results or later patches', async () => {
+ const error = new Error('subscription cache write failed');
+ vi.spyOn(host, 'writeQuery').mockRejectedValueOnce(error);
+ const onCacheError = vi.fn();
+ const patches = [
+ {
+ __typename: 'SoupUpdated',
+ item: {
+ __typename: 'GraphqlSoupDocument',
+ id: 'document-1',
+ displayName: 'Updated document',
+ },
+ },
+ {
+ __typename: 'GraphqlCacheDeletion',
+ graphqlTypeName: 'GraphqlSoupDocument',
+ entityId: 'document-2',
+ },
+ ];
+ const data = { soupUpdates: patches };
+ const { ops, results } = harness(
+ host,
+ (op) => (op.kind === 'subscription' ? { data } : {}),
+ { onCacheError }
+ );
+
+ const operation = makeSubscriptionOp(24);
+ ops.next(operation);
+ await tick();
+
+ expect(onCacheError).toHaveBeenCalledWith(error, operation);
+ expect(host.invalidations).toEqual([['GraphqlSoupDocument:document-2']]);
+ expect(results).toHaveLength(1);
+ expect(results[0]?.data).toBe(data);
+ });
+
it('cache-first miss forwards to network and writes through', async () => {
const { ops, results, forwarded } = harness(host);
ops.next(makeOp(1));
diff --git a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.ts b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.ts
index dcd4eac88d..98bc5b8352 100644
--- a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.ts
+++ b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.ts
@@ -280,6 +280,62 @@ function mutationCacheKeys(data: unknown, op: Operation): string[] {
return [...keys];
}
+type SubscriptionCacheEffect =
+ | { kind: 'write'; data: unknown }
+ | { kind: 'delete'; key: string };
+
+/** Returns the normalized key carried by the cache-deletion GraphQL type. */
+function graphqlCacheDeletionKey(value: unknown): string | undefined {
+ if (value === null || typeof value !== 'object') return;
+ const record = value as Record<string, unknown>;
+ if (
+ record.__typename !== 'GraphqlCacheDeletion' ||
+ typeof record.graphqlTypeName !== 'string' ||
+ typeof record.entityId !== 'string'
+ ) {
+ return;
+ }
+ return `${record.graphqlTypeName}:${record.entityId}`;
+}
+
+/**
+ * Converts a subscription payload into ordered cache effects. Ordinary
+ * subscription data is normalized without knowing its schema shape. The only
+ * special case is `GraphqlCacheDeletion`; when it occurs in a buffered root
+ * list, surrounding values are written as singleton list results so event
+ * order remains observable by the cache.
+ */
+function subscriptionCacheEffects(data: unknown): SubscriptionCacheEffect[] {
+ if (data === null || typeof data !== 'object' || Array.isArray(data)) {
+ return [{ kind: 'write', data }];
+ }
+
+ // GraphQL subscriptions have exactly one root field (which may be aliased).
+ const rootFields = Object.entries(data);
+ if (rootFields.length !== 1) return [{ kind: 'write', data }];
+
+ const [responseKey, payload] = rootFields[0] as [string, unknown];
+ if (Array.isArray(payload)) {
+ const hasDeletion = payload.some(
+ (value) => graphqlCacheDeletionKey(value) !== undefined
+ );
+ if (!hasDeletion) return [{ kind: 'write', data }];
+
+ return payload.map((value) => {
+ const key = graphqlCacheDeletionKey(value);
+ return key
+ ? { kind: 'delete' as const, key }
+ : {
+ kind: 'write' as const,
+ data: { [responseKey]: [value] },
+ };
+ });
+ }
+
+ const key = graphqlCacheDeletionKey(payload);
+ return key ? [{ kind: 'delete', key }] : [{ kind: 'write', data }];
+}
+
function queuedMutationResult(
op: Operation,
transactionId: string
@@ -354,6 +410,7 @@ export function normalizedCacheExchange(
resolveRoute: (result: OperationResult | undefined) => void;
}
>();
+ const subscriptionEffectChains = new Map<number, Promise<void>>();
let attemptInFlight = false;
let drainRunning = false;
let deferredUntil: number | undefined;
@@ -592,7 +649,44 @@ export function normalizedCacheExchange(
result: OperationResult
): Promise<OperationResult> {
const op = result.operation;
- if (op.kind === 'query' && result.data != null) {
+ if (op.kind === 'subscription' && result.data != null) {
+ // Serialize effects across every emission for this operation, as
+ // well as within buffered payloads, so a slower earlier write cannot
+ // overtake a later delete. Subscribers still receive each original
+ // result after its effects settle.
+ const previousEffects =
+ subscriptionEffectChains.get(op.key) ?? Promise.resolve();
+ const effects = previousEffects.then(async () => {
+ for (const effect of subscriptionCacheEffects(result.data)) {
+ try {
+ if (effect.kind === 'write') {
+ await host.writeQuery({
+ query: queryText(op),
+ operationName: operationName(op),
+ variables: op.variables as
+ | Record<string, unknown>
+ | undefined,
+ data: effect.data,
+ });
+ } else {
+ await host.deleteRecords([effect.key]);
+ }
+ } catch (error) {
+ // One failed cache effect must neither skip later effects nor
+ // terminate the subscription result stream.
+ options.onCacheError?.(error, op);
+ }
+ }
+ });
+ subscriptionEffectChains.set(op.key, effects);
+ try {
+ await effects;
+ } finally {
+ if (subscriptionEffectChains.get(op.key) === effects) {
+ subscriptionEffectChains.delete(op.key);
+ }
+ }
+ } else if (op.kind === 'query' && result.data != null) {
try {
await host.writeQuery({
opKey: op.key,
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts
new file mode 100644
index 0000000000..4e40b676a5
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts
@@ -0,0 +1,89 @@
+import { describe, expect, it, vi } from 'vitest';
+import {
+ buildGraphqlSoupWebSocketUrl,
+ createGraphqlSoupWebSocketUrlResolver,
+ createSoupUpdatesSubscriptionLifecycle,
+} from './graphql-soup-websocket';
+
+describe('GraphQL Soup websocket auth', () => {
+ it('maps HTTP protocols and appends encoded bearer auth', () => {
+ expect(
+ buildGraphqlSoupWebSocketUrl(
+ 'https://cloud-storage.macro.com',
+ 'token+/='
+ )
+ ).toBe(
+ 'wss://cloud-storage.macro.com/items/soup/graphql/ws?macro-api-token=token%2B%2F%3D'
+ );
+ expect(buildGraphqlSoupWebSocketUrl('http://localhost:8086')).toBe(
+ 'ws://localhost:8086/items/soup/graphql/ws'
+ );
+ });
+
+ it('refreshes cookie auth before resolving each connection URL', async () => {
+ const refreshCookieAuth = vi.fn().mockResolvedValue(undefined);
+ const getApiToken = vi.fn();
+ const resolveUrl = createGraphqlSoupWebSocketUrlResolver({
+ dssHost: 'https://cloud-storage.macro.com',
+ bearerTokenAuth: false,
+ getApiToken,
+ refreshCookieAuth,
+ });
+
+ await expect(resolveUrl()).resolves.toBe(
+ 'wss://cloud-storage.macro.com/items/soup/graphql/ws'
+ );
+ expect(refreshCookieAuth).toHaveBeenCalledOnce();
+ expect(getApiToken).not.toHaveBeenCalled();
+ });
+
+ it('refreshes bearer auth in the URL on every connection attempt', async () => {
+ const getApiToken = vi
+ .fn()
+ .mockResolvedValueOnce('first')
+ .mockResolvedValueOnce('second');
+ const refreshCookieAuth = vi.fn();
+ const resolveUrl = createGraphqlSoupWebSocketUrlResolver({
+ dssHost: 'https://cloud-storage.macro.com',
+ bearerTokenAuth: true,
+ getApiToken,
+ refreshCookieAuth,
+ });
+
+ await expect(resolveUrl()).resolves.toContain('macro-api-token=first');
+ await expect(resolveUrl()).resolves.toContain('macro-api-token=second');
+ expect(refreshCookieAuth).not.toHaveBeenCalled();
+ });
+});
+
+describe('Soup updates subscription lifecycle', () => {
+ it('keeps one subscription, cleans up replacements, and skips disabled hosts', () => {
+ const firstUnsubscribe = vi.fn();
+ const secondUnsubscribe = vi.fn();
+ const firstClient = {
+ subscription: vi.fn(() => ({
+ subscribe: vi.fn(() => ({ unsubscribe: firstUnsubscribe })),
+ })),
+ };
+ const secondClient = {
+ subscription: vi.fn(() => ({
+ subscribe: vi.fn(() => ({ unsubscribe: secondUnsubscribe })),
+ })),
+ };
+ const lifecycle = createSoupUpdatesSubscriptionLifecycle();
+
+ lifecycle.replace(firstClient as never, { disabled: false } as never);
+ expect(firstClient.subscription).toHaveBeenCalledOnce();
+
+ lifecycle.replace(secondClient as never, { disabled: false } as never);
+ expect(firstUnsubscribe).toHaveBeenCalledOnce();
+ expect(secondClient.subscription).toHaveBeenCalledOnce();
+
+ lifecycle.replace(firstClient as never, { disabled: true } as never);
+ expect(secondUnsubscribe).toHaveBeenCalledOnce();
+ expect(firstClient.subscription).toHaveBeenCalledOnce();
+
+ lifecycle.dispose();
+ expect(secondUnsubscribe).toHaveBeenCalledOnce();
+ });
+});
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts
new file mode 100644
index 0000000000..4264c25f0c
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts
@@ -0,0 +1,81 @@
+import type { CacheHost } from '@graphql-cache/host/types';
+import type { Client } from '@urql/core';
+import { SoupUpdatesDocument } from './graphql/generated/graphql';
+
+const SOUP_GRAPHQL_WEBSOCKET_PATH = '/items/soup/graphql/ws';
+
+/** Converts a DSS HTTP origin into its Soup GraphQL websocket endpoint. */
+export function buildGraphqlSoupWebSocketUrl(
+ dssHost: string,
+ apiToken?: string
+): string {
+ const url = new URL(
+ `${dssHost.replace(/\/$/, '')}${SOUP_GRAPHQL_WEBSOCKET_PATH}`
+ );
+ if (url.protocol === 'http:') url.protocol = 'ws:';
+ else if (url.protocol === 'https:') url.protocol = 'wss:';
+ else if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {
+ throw new Error(`unsupported GraphQL websocket protocol ${url.protocol}`);
+ }
+ if (apiToken) url.searchParams.set('macro-api-token', apiToken);
+ return url.toString();
+}
+
+type GraphqlSoupWebSocketAuth = {
+ dssHost: string;
+ bearerTokenAuth: boolean;
+ getApiToken: () => Promise<string>;
+ refreshCookieAuth: () => Promise<void>;
+};
+
+/** Creates the reconnect-safe URL resolver used by graphql-ws. */
+export function createGraphqlSoupWebSocketUrlResolver({
+ dssHost,
+ bearerTokenAuth,
+ getApiToken,
+ refreshCookieAuth,
+}: GraphqlSoupWebSocketAuth): () => Promise<string> {
+ return async () => {
+ if (bearerTokenAuth) {
+ const apiToken = await getApiToken();
+ if (!apiToken) throw new Error('No Macro API token');
+ return buildGraphqlSoupWebSocketUrl(dssHost, apiToken);
+ }
+
+ // Browsers authenticate the websocket upgrade with the refreshed cookie.
+ await refreshCookieAuth();
+ return buildGraphqlSoupWebSocketUrl(dssHost);
+ };
+}
+
+/** Owns the one Soup update subscription for a page context. */
+export function createSoupUpdatesSubscriptionLifecycle(): {
+ replace(client?: Pick<Client, 'subscription'>, host?: CacheHost): void;
+ dispose(): void;
+} {
+ let unsubscribe: (() => void) | undefined;
+
+ return {
+ replace(client, host) {
+ unsubscribe?.();
+ unsubscribe = undefined;
+ if (!client || !host || host.disabled) return;
+
+ const subscription = client
+ .subscription(SoupUpdatesDocument, {})
+ .subscribe((result) => {
+ if (result.error) {
+ console.warn(
+ 'GraphQL Soup updates subscription error',
+ result.error
+ );
+ }
+ });
+ unsubscribe = () => subscription.unsubscribe();
+ },
+ dispose() {
+ unsubscribe?.();
+ unsubscribe = undefined;
+ },
+ };
+}
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts
index 71f8dafacf..6c27af52ff 100644
--- a/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts
+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts
@@ -15,7 +15,17 @@ import {
import { registerCacheHost } from '@graphql-cache/lifecycle';
import { getOrCreateCacheScope } from '@graphql-cache/scope';
import { getMacroApiToken } from '@service-auth/fetch';
-import { type Client, createClient, fetchExchange } from '@urql/core';
+import {
+ type Client,
+ createClient,
+ fetchExchange,
+ subscriptionExchange,
+} from '@urql/core';
+import { print } from 'graphql';
+import {
+ createClient as createGraphqlWsClient,
+ type Client as GraphqlWsClient,
+} from 'graphql-ws';
import { match } from 'ts-pattern';
import type { SoupApiItem } from './generated/schemas/soupApiItem';
import type { SoupPage } from './generated/schemas/soupPage';
@@ -30,6 +40,7 @@ import {
SoupDocument as SoupQueryDocument,
type SoupQueryVariables,
} from './graphql/generated/graphql';
+import { createGraphqlSoupWebSocketUrlResolver } from './graphql-soup-websocket';
const dssHost = SERVER_HOSTS['document-storage-service'];
@@ -104,11 +115,13 @@ export function getGraphqlSoupClient(): Client {
if (!graphqlCacheEnabled()) return graphqlSoupClient;
cachedClient ??= (() => {
let host: CacheHost | undefined;
+ let websocketClient: GraphqlWsClient | undefined;
let unregisterHost: () => void = () => undefined;
const onInitializationError = (error: Error) => {
if (!host || cachedCacheHost !== host) return;
unregisterHost();
host.dispose();
+ if (websocketClient) void websocketClient.dispose();
cachedCacheHost = undefined;
cachedClient = graphqlSoupClient;
console.warn(
@@ -121,6 +134,23 @@ export function getGraphqlSoupClient(): Client {
host = isTauri()
? createTauriCacheHost({ scope, onInitializationError })
: createWorkerCacheHost({ scope, onInitializationError });
+ const resolveWebSocketUrl = createGraphqlSoupWebSocketUrlResolver({
+ dssHost,
+ bearerTokenAuth: ENABLE_BEARER_TOKEN_AUTH,
+ getApiToken: getMacroApiToken,
+ refreshCookieAuth: async () => {
+ const result = await fetchToken();
+ if (result.isErr()) {
+ throw new Error('Unable to refresh GraphQL websocket cookie');
+ }
+ },
+ });
+ const graphqlWsClient = createGraphqlWsClient({
+ url: resolveWebSocketUrl,
+ retryAttempts: Number.POSITIVE_INFINITY,
+ shouldRetry: () => true,
+ });
+ websocketClient = graphqlWsClient;
const client = createClient({
url: `${dssHost}/items/soup/graphql`,
exchanges: [
@@ -135,6 +165,25 @@ export function getGraphqlSoupClient(): Client {
// GraphQL application errors are permanent and roll back.
shouldRetryMutation: (error) => error.networkError != null,
}),
+ subscriptionExchange({
+ forwardSubscription(payload, request) {
+ const graphqlWsPayload = {
+ query: print(request.query),
+ operationName: payload.operationName,
+ variables: payload.variables,
+ extensions: payload.extensions,
+ };
+ return {
+ subscribe(sink) {
+ const unsubscribe = graphqlWsClient.subscribe(
+ graphqlWsPayload,
+ sink
+ );
+ return { unsubscribe };
+ },
+ };
+ },
+ }),
fetchExchange,
],
fetch: dssGraphqlFetch,
@@ -143,7 +192,9 @@ export function getGraphqlSoupClient(): Client {
unregisterHost = registerCacheHost(host);
return client;
} catch (error) {
+ unregisterHost();
host?.dispose();
+ if (websocketClient) void websocketClient.dispose();
cachedCacheHost = undefined;
console.warn('graphql cache init failed; using uncached client', error);
return graphqlSoupClient;
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts b/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts
index 2d1a0148d3..8ea6c3c316 100644
--- a/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts
+++ b/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts
@@ -1126,6 +1126,75 @@ export type SetEntityPropertyMutation = { setEntityProperty: { id: string, prope
| { __typename: 'GraphqlStringPropertyValue', stringValue: string }
| null } };
+export type SoupUpdatesSubscriptionVariables = Exact<{ [key: string]: never; }>;
+
+
+export type SoupUpdatesSubscription = { soupUpdates: Array<
+ | { __typename: 'GraphqlCacheDeletion', graphqlTypeName: string, entityId: string }
+ | { __typename: 'SoupUpdated', item:
+ | { __typename: 'GraphqlSoupCall', channelId: string, channelName: string | null, createdBy: string, customName: string | null, summary: string | null, startedAt: string, endedAt: string | null, durationMs: number | null, isActive: boolean, status: string, attended: boolean, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, participants: Array<{ userId: string, joinedAt: string, leftAt: string | null }>, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupChannel', channelType: string, ownerId: string, organizationId: string | null, createdAt: string, updatedAt: string, viewedAt: string | null, interactedAt: string | null, isParticipant: boolean, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, channelName: string | null, channelTeamId: string | null, participants: Array<{ channelId: string, userId: string, role: string, joinedAt: string, leftAt: string | null }>, latestMessage: { messageId: string, channelId: string, threadId: string | null, senderId: string, content: string, createdAt: string, updatedAt: string, deletedAt: string | null, mentions: Array<string> } | null, latestNonThreadMessage: { messageId: string, channelId: string, threadId: string | null, senderId: string, content: string, createdAt: string, updatedAt: string, deletedAt: string | null, mentions: Array<string> } | null, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupChannelMessage', channelId: string, senderId: string, content: string, createdAt: string, updatedAt: string, effectiveUpdatedAt: string, replyCount: number, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupChat', ownerId: string, projectId: string | null, isPersistent: boolean, createdAt: string, updatedAt: string, viewedAt: string | null, deletedAt: string | null, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, chatName: string, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupCrmCompany', description: string | null, emailSync: boolean, hidden: boolean, createdAt: string, updatedAt: string, viewedAt: string | null, domains: Array<string>, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, crmTeamId: string, crmCompanyName: string | null, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupDocument', ownerId: string, fileType: string | null, projectId: string | null, createdAt: string, updatedAt: string, viewedAt: string | null, deletedAt: string | null, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, documentName: string, subType:
+ | { __typename: 'GraphqlSnippetSubType' }
+ | { __typename: 'GraphqlTaskSubType', isCompleted: boolean }
+ | null, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupEmailThread', providerId: string | null, ownerId: string, inboxVisible: boolean, linkId: string | null, snippet: string | null, senderEmail: string | null, senderName: string | null, senderPhotoUrl: string | null, isRead: boolean, isDraft: boolean, isImportant: boolean, projectId: string | null, sortTs: string, createdAt: string, updatedAt: string, viewedAt: string | null, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, emailName: string | null, participants: Array<{ id: string, linkId: string, name: string | null, email: string | null, sfsPhotoUrl: string | null }>, attachments: Array<{ id: string, messageId: string, providerAttachmentId: string | null, filename: string | null, mimeType: string | null, sizeBytes: number | null, contentId: string | null, createdAt: string }>, labels: Array<{ id: string, linkId: string, providerLabelId: string, name: string, createdAt: string, messageListVisibility: string, labelListVisibility: string, type: string }>, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, latestContentMessage: { __typename: 'GraphqlSoupEmailMessage', id: string, threadId: string, linkId: string, subject: string | null, snippet: string | null, internalDateTs: string | null, sentAt: string | null, isRead: boolean, isStarred: boolean, isSent: boolean, hasAttachments: boolean, bodyParsed: string | null, bodyText: string | null, bodyHtmlSanitized: string | null, bodyMacro: string | null, bodyReplyless: string | null, createdAt: string, updatedAt: string, from: { email: string, name: string | null, photoUrl: string | null } | null, to: Array<{ email: string, name: string | null, photoUrl: string | null }>, cc: Array<{ email: string, name: string | null, photoUrl: string | null }>, bcc: Array<{ email: string, name: string | null, photoUrl: string | null }>, labels: Array<{ providerLabelId: string, name: string }> } | null, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupForeignEntity', foreignEntityId: string, foreignEntitySource: string, storedForId: string, storedForAuthEntity: string, sourceMetadata: unknown, createdAt: string, updatedAt: string, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | { __typename: 'GraphqlSoupProject', ownerId: string, parentId: string | null, createdAt: string, updatedAt: string, viewedAt: string | null, deletedAt: string | null, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, projectName: string, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:
+ | { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }
+ | { __typename: 'GraphqlDatePropertyValue', dateValue: string }
+ | { __typename: 'GraphqlEntityReferencePropertyValue', references: Array<{ entityId: string, entityType: GraphqlPropertyEntityType, specificMessageId: string | null }> }
+ | { __typename: 'GraphqlLinkPropertyValue', urls: Array<string> }
+ | { __typename: 'GraphqlNumberPropertyValue', numberValue: number }
+ | { __typename: 'GraphqlSelectOptionPropertyValue', optionIds: Array<string> }
+ | { __typename: 'GraphqlStringPropertyValue', stringValue: string }
+ | null }>, notifications: Array<{ id: string, eventType: string, entityType: GraphqlSoupEntityType, entityId: string, sent: boolean, done: boolean, seen: boolean, createdAt: string, viewedAt: string | null, updatedAt: string, senderId: string | null, metadata: unknown }> }
+ | null }
+ > };
+
export type SoupQueryVariables = Exact<{
input: SoupInput;
}>;
@@ -1339,4 +1408,5 @@ export const SetEntityFavoriteDocument = {"kind":"Document","definitions":[{"kin
export const GroupSoupMembershipDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GroupSoupMembership"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GroupedSoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"groupSoup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bins"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<GroupSoupMembershipQuery, GroupSoupMembershipQueryVariables>;
export const GroupSoupDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GroupSoup"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GroupedSoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"groupSoup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bins"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<GroupSoupQuery, GroupSoupQueryVariables>;
export const SetEntityPropertyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SetEntityProperty"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SetEntityPropertyInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"setEntityProperty"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}}]} as unknown as DocumentNode<SetEntityPropertyMutation, SetEntityPropertyMutationVariables>;
+export const SoupUpdatesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"subscription","name":{"kind":"Name","value":"SoupUpdates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"soupUpdates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"SoupUpdated"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"item"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlCacheDeletion"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"graphqlTypeName"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<SoupUpdatesSubscription, SoupUpdatesSubscriptionVariables>;
export const SoupDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Soup"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"soup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<SoupQuery, SoupQueryVariables>;
\ No newline at end of file
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql/soup-updates.graphql b/apps/web/src/lib/service-clients/service-storage/graphql/soup-updates.graphql
new file mode 100644
index 0000000000..25f7434dc9
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/graphql/soup-updates.graphql
@@ -0,0 +1,14 @@
+subscription SoupUpdates {
+ soupUpdates {
+ __typename
+ ... on SoupUpdated {
+ item {
+ ...SoupItemFields
+ }
+ }
+ ... on GraphqlCacheDeletion {
+ graphqlTypeName
+ entityId
+ }
+ }
+}
diff --git a/bun.lock b/bun.lock
index 79253f713a..c50775c0c6 100644
--- a/bun.lock
+++ b/bun.lock
@@ -85,6 +85,7 @@
"email-validator": "^2.0.4",
"emojibase-data": "^17.0.0",
"emojilib": "^4.0.2",
+ "graphql-ws": "^6.1.0",
"katex": "^0.16.22",
"lexical": "0.45.0",
"libheif-js": "^1.19.8",
diff --git a/crates/client/cache-core/build.rs b/crates/client/cache-core/build.rs
index 1330615e46..b92797f22f 100644
--- a/crates/client/cache-core/build.rs
+++ b/crates/client/cache-core/build.rs
@@ -47,6 +47,11 @@ fn main() {
.mutation
.as_ref()
.map(|m| m.name.to_string());
+ let subscription_root = schema
+ .schema_definition
+ .subscription
+ .as_ref()
+ .map(|subscription| subscription.name.to_string());
// The schema hash namespaces persisted caches; key policy is derived
// from the schema, so hashing the schema covers it.
@@ -77,7 +82,9 @@ fn main() {
}
match ty {
ExtendedType::Object(obj) => {
- let is_operation_root = name == query_root || Some(&name) == mutation_root.as_ref();
+ let is_operation_root = name == query_root
+ || Some(&name) == mutation_root.as_ref()
+ || Some(&name) == subscription_root.as_ref();
let key_literal =
key_literal(&name, is_operation_root, obj.fields.iter(), &mut errors);
let fields = fields_literal(&schema, obj.fields.iter(), &mut errors);
@@ -131,6 +138,18 @@ fn main() {
.unwrap(),
None => writeln!(out, "pub static MUTATION_ROOT_TYPE: Option<&str> = None;").unwrap(),
}
+ match &subscription_root {
+ Some(name) => writeln!(
+ out,
+ "pub static SUBSCRIPTION_ROOT_TYPE: Option<&str> = Some({name:?});"
+ )
+ .unwrap(),
+ None => writeln!(
+ out,
+ "pub static SUBSCRIPTION_ROOT_TYPE: Option<&str> = None;"
+ )
+ .unwrap(),
+ }
writeln!(out, "pub static SCHEMA_HASH: &str = {schema_hash:?};").unwrap();
writeln!(out, "pub static TYPES: &[TypeMeta] = &[").unwrap();
for (_, literal) in &entries {
diff --git a/crates/client/cache-core/src/document.rs b/crates/client/cache-core/src/document.rs
index 23e3949d2b..10e087295a 100644
--- a/crates/client/cache-core/src/document.rs
+++ b/crates/client/cache-core/src/document.rs
@@ -20,7 +20,7 @@ pub enum DocumentError {
NoOperation,
#[error("operation `{0}` not found")]
UnknownOperation(String),
- #[error("only queries and mutations are supported (got {0})")]
+ #[error("unsupported operation type: {0}")]
UnsupportedOperationType(String),
#[error("fragment `{0}` is not defined")]
UnknownFragment(String),
@@ -59,11 +59,12 @@ pub enum Selection {
},
}
-/// Kind of an executable operation. Subscriptions are rejected at parse.
+/// Kind of an executable operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OperationKind {
Query,
Mutation,
+ Subscription,
}
#[derive(Debug, Clone)]
@@ -135,7 +136,7 @@ impl Document {
None => OperationKind::Query,
Some(ty) if ty.query_token().is_some() => OperationKind::Query,
Some(ty) if ty.mutation_token().is_some() => OperationKind::Mutation,
- // Subscriptions are not cacheable.
+ Some(ty) if ty.subscription_token().is_some() => OperationKind::Subscription,
Some(ty) => {
let label = ty.syntax().text().to_string();
return Err(DocumentError::UnsupportedOperationType(label));
@@ -495,17 +496,17 @@ mod tests {
OperationKind::Mutation
);
+ let doc = Document::parse("subscription S { soupUpdates { __typename } }").unwrap();
+ assert_eq!(
+ doc.operation(Some("S")).unwrap().kind,
+ OperationKind::Subscription
+ );
+
// Shorthand operations are queries.
let doc = Document::parse("{ user { id } }").unwrap();
assert_eq!(doc.operation(None).unwrap().kind, OperationKind::Query);
}
- #[test]
- fn rejects_subscriptions() {
- let err = Document::parse("subscription S { doThing }").unwrap_err();
- assert!(matches!(err, DocumentError::UnsupportedOperationType(_)));
- }
-
#[test]
fn rejects_unknown_fragment() {
let err = Document::parse("query Q { a { ...Nope } }").unwrap_err();
diff --git a/crates/client/cache-core/src/engine.rs b/crates/client/cache-core/src/engine.rs
index f919bb16eb..e91f06014e 100644
--- a/crates/client/cache-core/src/engine.rs
+++ b/crates/client/cache-core/src/engine.rs
@@ -343,7 +343,10 @@ impl<S: Storage> Engine<S> {
let op = doc.operation(operation_name)?;
if op.kind != OperationKind::Query {
return Err(EngineError::Document(
- DocumentError::UnsupportedOperationType("mutation (reads are query-only)".into()),
+ DocumentError::UnsupportedOperationType(format!(
+ "{:?} (cache reads are query-only)",
+ op.kind
+ )),
));
}
diff --git a/crates/client/cache-core/src/meta.rs b/crates/client/cache-core/src/meta.rs
index 118c62f97f..0ca4f50328 100644
--- a/crates/client/cache-core/src/meta.rs
+++ b/crates/client/cache-core/src/meta.rs
@@ -110,6 +110,15 @@ mod tests {
assert!(root.fields.iter().any(|f| f.name == "setEntityProperty"));
}
+ #[test]
+ fn subscription_root_is_present() {
+ let name = SUBSCRIPTION_ROOT_TYPE.expect("schema has a subscription root");
+ let root = type_meta(name).expect("subscription root type");
+ assert_eq!(root.kind, TypeKind::Object);
+ assert!(root.key_fields.is_none());
+ assert!(root.fields.iter().any(|field| field.name == "soupUpdates"));
+ }
+
#[test]
fn interface_possible_types() {
let entity = type_meta("GraphqlSoupEntity").expect("entity interface");
diff --git a/crates/client/cache-core/src/normalize.rs b/crates/client/cache-core/src/normalize.rs
index 62e6a50b68..284dabe276 100644
--- a/crates/client/cache-core/src/normalize.rs
+++ b/crates/client/cache-core/src/normalize.rs
@@ -41,10 +41,9 @@ pub type RecordUpdates = BTreeMap<EntityKey, Record>;
/// Normalizes a response's `data` object into record updates.
///
/// Query responses are rooted at [`ROOT_QUERY`](crate::value::ROOT_QUERY).
-/// Mutation responses traverse from the schema's mutation root: entities in
-/// the payload are normalized as usual, but the root mutation fields
-/// themselves are discarded — mutation roots are transient cache entry
-/// points, never read back.
+/// Mutation and subscription responses traverse from their schema roots:
+/// nested entities are normalized as usual, but operation-root fields are
+/// discarded. Those roots are transient cache entry points, never read back.
pub fn normalize(
op: &Operation,
variables: &serde_json::Map<String, Json>,
@@ -54,6 +53,8 @@ pub fn normalize(
OperationKind::Query => meta::QUERY_ROOT_TYPE,
OperationKind::Mutation => meta::MUTATION_ROOT_TYPE
.ok_or_else(|| NormalizeError::UnknownType("(mutation root)".to_string()))?,
+ OperationKind::Subscription => meta::SUBSCRIPTION_ROOT_TYPE
+ .ok_or_else(|| NormalizeError::UnknownType("(subscription root)".to_string()))?,
};
let Json::Object(data) = data else {
return Err(NormalizeError::Shape {
diff --git a/crates/client/cache-core/tests/subscription.rs b/crates/client/cache-core/tests/subscription.rs
new file mode 100644
index 0000000000..715f0c233a
--- /dev/null
+++ b/crates/client/cache-core/tests/subscription.rs
@@ -0,0 +1,118 @@
+use cache_core::document::{Document, OperationKind};
+use cache_core::engine::{Engine, EngineError};
+use cache_core::normalize::normalize;
+use cache_core::store::{InMemoryStorage, Storage};
+use cache_core::value::{CacheValue, EntityKey};
+use pollster::block_on;
+use serde_json::json;
+
+const SOUP_UPDATES_SUBSCRIPTION: &str = r#"
+subscription SoupUpdates {
+ soupUpdates {
+ __typename
+ ... on SoupUpdated {
+ item {
+ __typename
+ id
+ displayName
+ }
+ }
+ ... on GraphqlCacheDeletion {
+ graphqlTypeName
+ entityId
+ }
+ }
+}
+"#;
+
+fn updated_document(display_name: &str) -> serde_json::Value {
+ json!({
+ "soupUpdates": [{
+ "__typename": "SoupUpdated",
+ "item": {
+ "__typename": "GraphqlSoupDocument",
+ "id": "doc-1",
+ "displayName": display_name
+ }
+ }]
+ })
+}
+
+#[test]
+fn subscription_normalization_persists_entities_but_not_the_root() {
+ let document = Document::parse(SOUP_UPDATES_SUBSCRIPTION).unwrap();
+ let operation = document.operation(Some("SoupUpdates")).unwrap();
+ assert_eq!(operation.kind, OperationKind::Subscription);
+
+ let updates = normalize(
+ operation,
+ &serde_json::Map::new(),
+ &updated_document("Updated"),
+ )
+ .unwrap();
+
+ assert_eq!(
+ updates.keys().collect::<Vec<_>>(),
+ vec![&EntityKey("GraphqlSoupDocument:doc-1".into())]
+ );
+ assert!(!updates.contains_key(&EntityKey::root()));
+ assert!(matches!(
+ updates[&EntityKey("GraphqlSoupDocument:doc-1".into())]
+ .fields
+ .get("displayName"),
+ Some(CacheValue::String(name)) if name == "Updated"
+ ));
+}
+
+#[test]
+fn engine_writes_subscription_entities_and_keeps_reads_query_only() {
+ block_on(async {
+ let mut engine = Engine::new(InMemoryStorage::new());
+ engine
+ .write_query(
+ None,
+ SOUP_UPDATES_SUBSCRIPTION,
+ Some("SoupUpdates"),
+ &serde_json::Map::new(),
+ &updated_document("Updated"),
+ None,
+ )
+ .await
+ .unwrap();
+ engine
+ .write_query(
+ None,
+ SOUP_UPDATES_SUBSCRIPTION,
+ Some("SoupUpdates"),
+ &serde_json::Map::new(),
+ &updated_document("Updated again"),
+ None,
+ )
+ .await
+ .unwrap();
+
+ let keys = [
+ EntityKey("GraphqlSoupDocument:doc-1".into()),
+ EntityKey::root(),
+ ];
+ let records = engine.storage().get_batch(&keys).await.unwrap();
+ assert!(matches!(
+ records[0]
+ .as_ref()
+ .and_then(|record| record.fields.get("displayName")),
+ Some(CacheValue::String(name)) if name == "Updated again"
+ ));
+ assert!(records[1].is_none());
+
+ let error = engine
+ .read_query(
+ None,
+ SOUP_UPDATES_SUBSCRIPTION,
+ Some("SoupUpdates"),
+ &serde_json::Map::new(),
+ )
+ .await
+ .unwrap_err();
+ assert!(matches!(error, EngineError::Document(_)));
+ });
+}
diff --git a/crates/complete_graph/src/schema.rs b/crates/complete_graph/src/schema.rs
index 36fb9f91c6..11b95c09ba 100644
--- a/crates/complete_graph/src/schema.rs
+++ b/crates/complete_graph/src/schema.rs
@@ -360,7 +360,7 @@ where
&self,
ctx: &Context<'_>,
) -> async_graphql::Result<
- impl async_graphql::futures_util::Stream<Item = SoupPatch<SoupEdges<NR, PR, ER, FR, AR>>>,
+ impl async_graphql::futures_util::Stream<Item = Vec<SoupPatch<SoupEdges<NR, PR, ER, FR, AR>>>>,
> {
resolve_soup_updates::<R, Auth, St, SoupEdges<NR, PR, ER, FR, AR>>(&self.service, ctx).await
}
diff --git a/crates/complete_graph/src/schema/test.rs b/crates/complete_graph/src/schema/test.rs
index d7af256f14..87d28eb813 100644
--- a/crates/complete_graph/src/schema/test.rs
+++ b/crates/complete_graph/src/schema/test.rs
@@ -23,7 +23,7 @@ use macro_user_id::{
};
use model_entity::EntityType as ModelEntityType;
use model_user::UserContext;
-use models_pagination::{PaginatedCursor, SimpleSortMethod};
+use models_pagination::{Paginated, PaginatedCursor, SimpleSortMethod};
use models_soup::{document::SoupDocument, item::SoupItem};
use rootcause::Report;
use soup_realtime::domain::models::Patch;
@@ -59,6 +59,7 @@ impl SoupRealtimeSubscriptionService for TestRealtimeSubscriptionService {
struct CountingSoupService {
raw_calls: Arc<AtomicUsize>,
raw_team_receipts: Arc<AtomicUsize>,
+ return_empty_raw: bool,
frecency_calls: Arc<AtomicUsize>,
frecency_team_receipts: Arc<AtomicUsize>,
grouped_calls: Arc<AtomicUsize>,
@@ -103,6 +104,11 @@ impl SoupService for CountingSoupService {
if team_receipt.is_some() {
self.raw_team_receipts.fetch_add(1, Ordering::SeqCst);
}
+ if self.return_empty_raw {
+ let page: PaginatedCursor<SoupItem<()>, String, SimpleSortMethod, T> =
+ Paginated::from_parts(Vec::new(), None);
+ return Ok(soup::domain::ports::SoupOutput::Left(page));
+ }
Err(test_soup_err())
}
@@ -596,13 +602,18 @@ async fn soup_updates_subscribes_as_the_authenticated_user() {
let user_id = MacroUserIdStr::parse_from_str(VALID_USER_ID).unwrap();
let subscribed_user = Arc::new(Mutex::new(None));
- let (sender, receiver) = tokio::sync::mpsc::channel(1);
+ let (sender, receiver) = tokio::sync::mpsc::channel(2);
let realtime = TestRealtimeSubscriptionService {
receiver: Arc::new(Mutex::new(Some(receiver))),
subscribed_user: Arc::clone(&subscribed_user),
};
+ let soup_service = CountingSoupService {
+ return_empty_raw: true,
+ ..Default::default()
+ };
+ let loader = graphql_soup::soup_item_loader(soup_service.clone(), Arc::new(NoOpEmailService));
let schema: SoupSchema<
- NoOpSoupService,
+ CountingSoupService,
TestRealtimeSubscriptionService,
NoOpEmailService,
NoOpEntityAccessService,
@@ -615,11 +626,12 @@ async fn soup_updates_subscribes_as_the_authenticated_user() {
NoOpSoupEmailContentEdgeReader,
NoOpEntityFavoriteEdgeReader,
NoOpEntityPermissionEdgeReader,
- > = build_schema_with_services(NoOpSoupService, realtime);
+ > = build_schema_with_services(soup_service, realtime);
let request = async_graphql::Request::new(
- "subscription { soupUpdates { operation entity { id entityType } } }",
+ "subscription { soupUpdates { __typename ... on SoupUpdated { item { id } } ... on GraphqlCacheDeletion { graphqlTypeName entityId } } }",
)
- .data(user_id.clone());
+ .data(user_id.clone())
+ .data(loader);
let responses = schema.execute_stream(request);
pin_mut!(responses);
@@ -630,13 +642,25 @@ async fn soup_updates_subscribes_as_the_authenticated_user() {
))
.await
.expect("subscription remains open");
+ sender
+ .send(Patch::Deleted(
+ ModelEntityType::Document.with_entity_string(document_id.to_string()),
+ ))
+ .await
+ .expect("subscription remains open");
let response = responses.next().await.expect("one subscription response");
assert!(response.errors.is_empty(), "{:?}", response.errors);
let data = response.data.into_json().expect("response data is JSON");
- assert_eq!(data["soupUpdates"]["operation"], "UPDATED");
- assert_eq!(data["soupUpdates"]["entity"]["id"], document_id.to_string());
- assert_eq!(data["soupUpdates"]["entity"]["entityType"], "DOCUMENT");
+ let updates = data["soupUpdates"]
+ .as_array()
+ .expect("soupUpdates is a buffered list");
+ assert_eq!(updates.len(), 2);
+ assert_eq!(updates[0]["__typename"], "SoupUpdated");
+ assert!(updates[0]["item"].is_null());
+ assert_eq!(updates[1]["__typename"], "GraphqlCacheDeletion");
+ assert_eq!(updates[1]["graphqlTypeName"], "GraphqlSoupDocument");
+ assert_eq!(updates[1]["entityId"], document_id.to_string());
assert_eq!(
subscribed_user
.lock()
diff --git a/crates/complete_graph/src/sdl_test.rs b/crates/complete_graph/src/sdl_test.rs
index 820deadb0a..bffa6a4981 100644
--- a/crates/complete_graph/src/sdl_test.rs
+++ b/crates/complete_graph/src/sdl_test.rs
@@ -35,12 +35,14 @@ fn soup_response_schema_exposes_frontend_fields() {
"deletedAt: String",
"type GraphqlSoupProject implements GraphqlSoupEntity {",
"parent: GraphqlEntity",
- "type SoupPatch {",
- "operation: GraphqlPatchOperation!",
- "entity: GraphqlEntity!",
+ "type GraphqlCacheDeletion {",
+ "graphqlTypeName: String!",
+ "entityId: ID!",
+ "type SoupUpdated {",
"item: GraphqlSoupEntity",
+ "union SoupPatch = SoupUpdated | GraphqlCacheDeletion",
"type SoupSubscriptionRoot {",
- "soupUpdates: SoupPatch!",
+ "soupUpdates: [SoupPatch!]!",
] {
assert_sdl_line(&sdl, expected);
}
diff --git a/crates/graphql_common/src/entity_type.rs b/crates/graphql_common/src/entity_type.rs
index 5ecba77721..8d9873b99f 100644
--- a/crates/graphql_common/src/entity_type.rs
+++ b/crates/graphql_common/src/entity_type.rs
@@ -1,4 +1,4 @@
-use async_graphql::{Enum, ID, Object};
+use async_graphql::{Enum, ID, Object, SimpleObject};
use model_entity::{Entity, EntityType};
/// GraphQL representation of Soup entity types.
@@ -150,11 +150,21 @@ impl<'a> GraphqlEntity<'a> {
}
}
-/// Operation carried by a realtime entity patch.
-#[derive(Enum, Clone, Copy, PartialEq, Eq)]
-pub enum GraphqlPatchOperation {
- /// The entity was created or updated.
- Updated,
- /// The entity was deleted.
- Deleted,
+/// Marker instructing a normalized GraphQL cache to delete one entity record.
+#[derive(SimpleObject)]
+pub struct GraphqlCacheDeletion {
+ /// Concrete GraphQL object type used in the normalized cache key.
+ pub graphql_type_name: String,
+ /// Identifier used in the normalized cache key.
+ pub entity_id: ID,
+}
+
+impl GraphqlCacheDeletion {
+ /// Constructs a cache deletion marker from its concrete GraphQL type and identifier.
+ pub fn new(graphql_type_name: impl Into<String>, entity_id: impl Into<ID>) -> Self {
+ Self {
+ graphql_type_name: graphql_type_name.into(),
+ entity_id: entity_id.into(),
+ }
+ }
}
diff --git a/crates/graphql_common/src/lib.rs b/crates/graphql_common/src/lib.rs
index c8d44f3547..4060c83622 100644
--- a/crates/graphql_common/src/lib.rs
+++ b/crates/graphql_common/src/lib.rs
@@ -22,7 +22,7 @@ mod request_context;
pub use authorization::require_authorized_user;
pub use entity_type::{
- GraphqlEntity, GraphqlEntityType, GraphqlPatchOperation, GraphqlSoupEntityType,
+ GraphqlCacheDeletion, GraphqlEntity, GraphqlEntityType, GraphqlSoupEntityType,
};
pub use extract::extract_part;
pub use filter_input::{IntoFilterExpr, optional_tree, parse_id, parse_macro_user_id, parse_uuid};
diff --git a/crates/graphql_soup/src/lib.rs b/crates/graphql_soup/src/lib.rs
index 750629f91d..29cea52739 100644
--- a/crates/graphql_soup/src/lib.rs
+++ b/crates/graphql_soup/src/lib.rs
@@ -26,6 +26,6 @@ pub use objects::{
GraphqlSoupChannelMessagePreview, GraphqlSoupChat, GraphqlSoupCrmCompany, GraphqlSoupDocument,
GraphqlSoupDocumentSubType, GraphqlSoupEmailThread, GraphqlSoupEntity,
GraphqlSoupForeignEntity, GraphqlSoupProject, GroupedSoup, SoupEntityEdges, SoupPage,
- SoupPatch,
+ SoupPatch, SoupUpdated,
};
pub use resolvers::{resolve_grouped_soup, resolve_soup, resolve_soup_updates};
diff --git a/crates/graphql_soup/src/loaders/test.rs b/crates/graphql_soup/src/loaders/test.rs
index f39ef31c3e..4785762fda 100644
--- a/crates/graphql_soup/src/loaders/test.rs
+++ b/crates/graphql_soup/src/loaders/test.rs
@@ -350,6 +350,23 @@ async fn context_loader_does_not_cache_across_realtime_updates() {
assert_eq!(calls.lock().expect("calls lock").len(), 2);
}
+#[tokio::test]
+async fn context_loader_returns_none_for_a_missing_item() {
+ let user_id = user("macro|[email protected]");
+ let entity = EntityType::Document.with_entity_string(Uuid::from_u128(21).to_string());
+ let loader = SoupItemDataLoader::new(SoupItemLoader::new(
+ RecordingSoupService::default(),
+ RecordingInboxReader::default(),
+ ));
+
+ let item = loader
+ .load_one((user_id, entity))
+ .await
+ .expect("missing item is not a loader failure");
+
+ assert!(item.is_none());
+}
+
#[test]
fn encodes_requested_ids_and_disables_unrequested_entity_branches() {
let first_document = Uuid::from_u128(21);
diff --git a/crates/graphql_soup/src/objects.rs b/crates/graphql_soup/src/objects.rs
index 2933844c3a..937fec4e80 100644
--- a/crates/graphql_soup/src/objects.rs
+++ b/crates/graphql_soup/src/objects.rs
@@ -1,12 +1,12 @@
use std::marker::PhantomData;
use async_graphql::{
- ComplexObject, Context, ID, Interface, Json, Object, ObjectType, OutputType, SimpleObject,
- Union,
+ Context, ID, Interface, Json, Object, ObjectType, OutputType, SimpleObject, Union,
};
-use graphql_common::{GraphqlEntity, GraphqlPatchOperation, GraphqlSoupEntityType};
+use graphql_common::{GraphqlCacheDeletion, GraphqlEntity, GraphqlSoupEntityType};
use graphql_permission::GraphqlEntityPermission;
use macro_user_id::user_id::MacroUserIdStr;
+use model_entity::Entity;
use models_pagination::PaginatedOpaqueCursor;
use models_soup::{
call_record::{SoupCallRecord, SoupCallRecordParticipant},
@@ -284,6 +284,22 @@ impl<E> GraphqlSoupEntity<E>
where
E: SoupEntityEdges,
{
+ /// Return the concrete GraphQL object name associated with a Soup entity type.
+ fn graphql_type_name_for(entity_type: model_entity::EntityType) -> String {
+ match GraphqlSoupEntityType::new(entity_type) {
+ GraphqlSoupEntityType::Document => GraphqlSoupDocument::<E>::type_name(),
+ GraphqlSoupEntityType::Chat => GraphqlSoupChat::<E>::type_name(),
+ GraphqlSoupEntityType::Project => GraphqlSoupProject::<E>::type_name(),
+ GraphqlSoupEntityType::EmailThread => GraphqlSoupEmailThread::<E>::type_name(),
+ GraphqlSoupEntityType::Channel => GraphqlSoupChannel::<E>::type_name(),
+ GraphqlSoupEntityType::ChannelMessage => GraphqlSoupChannelMessage::<E>::type_name(),
+ GraphqlSoupEntityType::Call => GraphqlSoupCall::<E>::type_name(),
+ GraphqlSoupEntityType::CrmCompany => GraphqlSoupCrmCompany::<E>::type_name(),
+ GraphqlSoupEntityType::ForeignEntity => GraphqlSoupForeignEntity::<E>::type_name(),
+ }
+ .into_owned()
+ }
+
/// Construct a GraphQL entity from a plain Soup item.
pub fn new(item: SoupItem<()>) -> Self {
match item {
@@ -1724,20 +1740,13 @@ impl_common_interface_edges!(
GraphqlSoupForeignEntity,
);
-/// Lightweight realtime Soup patch with optional lazy item hydration.
-#[derive(SimpleObject)]
-#[graphql(complex)]
-pub struct SoupPatch<E: SoupEntityEdges> {
- /// Operation represented by this patch.
- operation: GraphqlPatchOperation,
- /// Canonical identity of the affected entity.
- entity: GraphqlEntity<'static>,
- /// User whose visibility scope must be used to hydrate the item.
- #[graphql(skip)]
- user_id: MacroUserIdStr<'static>,
- /// Associates the patch with its composed Soup edge object.
- #[graphql(skip)]
- phantom: PhantomData<E>,
+/// Realtime Soup patch represented as exactly one update or cache deletion.
+#[derive(Union)]
+pub enum SoupPatch<E: SoupEntityEdges> {
+ /// An entity that was created or updated.
+ Updated(SoupUpdated<E>),
+ /// A normalized entity record that must be deleted.
+ Deleted(GraphqlCacheDeletion),
}
impl<E: SoupEntityEdges> SoupPatch<E> {
@@ -1746,29 +1755,41 @@ impl<E: SoupEntityEdges> SoupPatch<E> {
user_id: MacroUserIdStr<'static>,
patch: Patch<model_entity::Entity<'static>>,
) -> Self {
- let (operation, entity) = match patch {
- Patch::Updated(entity) => (GraphqlPatchOperation::Updated, entity),
- Patch::Deleted(entity) => (GraphqlPatchOperation::Deleted, entity),
- };
- Self {
- operation,
- entity: GraphqlEntity(entity),
- user_id,
- phantom: PhantomData,
+ match patch {
+ Patch::Updated(entity) => Self::Updated(SoupUpdated {
+ entity,
+ user_id,
+ phantom: PhantomData,
+ }),
+ Patch::Deleted(entity) => {
+ let graphql_type_name =
+ GraphqlSoupEntity::<E>::graphql_type_name_for(entity.entity_type);
+ Self::Deleted(GraphqlCacheDeletion::new(
+ graphql_type_name,
+ ID(entity.entity_id.into_owned()),
+ ))
+ }
}
}
}
-#[ComplexObject]
-impl<E: SoupEntityEdges> SoupPatch<E> {
- /// Hydrate the current Soup item only when selected by the client.
- async fn item(&self, ctx: &Context<'_>) -> async_graphql::Result<Option<GraphqlSoupEntity<E>>> {
- if self.operation == GraphqlPatchOperation::Deleted {
- return Ok(None);
- }
+/// Created or updated Soup entity whose current data is hydrated when selected.
+pub struct SoupUpdated<E: SoupEntityEdges> {
+ /// Canonical entity to hydrate.
+ entity: Entity<'static>,
+ /// User whose visibility scope must be used to hydrate the item.
+ user_id: MacroUserIdStr<'static>,
+ /// Associates the update with its composed Soup edge object.
+ phantom: PhantomData<E>,
+}
+/// GraphQL representation of a created or updated Soup entity.
+#[Object]
+impl<E: SoupEntityEdges> SoupUpdated<E> {
+ /// Hydrate the current Soup entity.
+ async fn item(&self, ctx: &Context<'_>) -> async_graphql::Result<Option<GraphqlSoupEntity<E>>> {
let loader = ctx.data::<SoupItemDataLoader>()?;
- let key = (self.user_id.clone(), self.entity.0.clone());
+ let key = (self.user_id.clone(), self.entity.clone());
Ok(loader.load_one(key).await?.map(GraphqlSoupEntity::new))
}
}
diff --git a/crates/graphql_soup/src/resolvers.rs b/crates/graphql_soup/src/resolvers.rs
index 20c43e020a..b82f31f11b 100644
--- a/crates/graphql_soup/src/resolvers.rs
+++ b/crates/graphql_soup/src/resolvers.rs
@@ -27,7 +27,7 @@ use crate::{
pub async fn resolve_soup_updates<R, Auth, St, Edges>(
service: &R,
ctx: &Context<'_>,
-) -> async_graphql::Result<impl Stream<Item = SoupPatch<Edges>> + Send + 'static>
+) -> async_graphql::Result<impl Stream<Item = Vec<SoupPatch<Edges>>> + Send + 'static>
where
R: SoupRealtimeSubscriptionService,
Auth: MacroAuthorizationService,
@@ -37,10 +37,13 @@ where
{
let macro_user_id = require_authorized_user::<Auth, St>(ctx).await?;
let mut receiver = service.subscribe(macro_user_id.clone());
+ const BUFFER_SIZE: usize = 10;
+ let mut buf = Vec::with_capacity(BUFFER_SIZE);
Ok(async_stream::stream! {
- while let Some(patch) = receiver.recv().await {
- yield SoupPatch::new(macro_user_id.clone(), patch);
+ while let x @ 1.. = receiver.recv_many(&mut buf, BUFFER_SIZE).await {
+ let out = buf.drain(..x).map(|patch| SoupPatch::new(macro_user_id.clone(), patch)).collect();
+ yield out;
}
})
}
diff --git a/static_assets/schema.graphql b/static_assets/schema.graphql
index 7e70fcf433..8749f3ae84 100644
--- a/static_assets/schema.graphql
+++ b/static_assets/schema.graphql
@@ -135,6 +135,20 @@ type GraphqlBooleanPropertyValue {
value: Boolean!
}
+"""
+Marker instructing a normalized GraphQL cache to delete one entity record.
+"""
+type GraphqlCacheDeletion {
+ """
+ Concrete GraphQL object type used in the normalized cache key.
+ """
+ graphqlTypeName: String!
+ """
+ Identifier used in the normalized cache key.
+ """
+ entityId: ID!
+}
+
"""
The two operands of a recursive `CallFilterExpr` binary expression.
"""
@@ -1284,20 +1298,6 @@ type GraphqlNumberPropertyValue {
value: Float!
}
-"""
-Operation carried by a realtime entity patch.
-"""
-enum GraphqlPatchOperation {
- """
- The entity was created or updated.
- """
- UPDATED
- """
- The entity was deleted.
- """
- DELETED
-}
-
"""
The two operands of a recursive `ProjectFilterExpr` binary expression.
"""
@@ -3271,22 +3271,9 @@ type SoupPage {
}
"""
-Lightweight realtime Soup patch with optional lazy item hydration.
+Realtime Soup patch represented as exactly one update or cache deletion.
"""
-type SoupPatch {
- """
- Operation represented by this patch.
- """
- operation: GraphqlPatchOperation!
- """
- Canonical identity of the affected entity.
- """
- entity: GraphqlEntity!
- """
- Hydrate the current Soup item only when selected by the client.
- """
- item: GraphqlSoupEntity
-}
+union SoupPatch = SoupUpdated | GraphqlCacheDeletion
"""
Root entry point for the complete GraphQL API.
@@ -3305,7 +3292,17 @@ type SoupSubscriptionRoot {
"""
Subscribe to realtime Soup updates for the authenticated user.
"""
- soupUpdates: SoupPatch!
+ soupUpdates: [SoupPatch!]!
+}
+
+"""
+GraphQL representation of a created or updated Soup entity.
+"""
+type SoupUpdated {
+ """
+ Hydrate the current Soup entity.
+ """
+ item: GraphqlSoupEntity
}
"""