Prevent leak between /metadata and /graphql GQL schemas (#17845)
## Fix resolver schema leaking between `/metadata` and `/graphql` endpoints ### Summary - Patch `@nestjs/graphql` to support a `resolverSchemaScope` option that filters resolvers at both schema generation and runtime, preventing cross-endpoint leaking - Introduce `@CoreResolver()` and `@MetadataResolver()` decorators to explicitly scope each resolver to its endpoint - Move most resolvers (auth, billing, workspace, user, etc.) to the metadata schema where the frontend expects them; only workflow and timeline calendar/messaging resolvers remain on `/graphql` - Fix frontend `SSEQuerySubscribeEffect` to use the default (metadata) Apollo client instead of the core client ### Problem NestJS GraphQL's module-based resolver discovery traverses transitive imports, causing resolvers from `/metadata` modules to leak into the `/graphql` schema and vice versa. This made the schemas unpredictable and tightly coupled to module import order. ### Approach - Added `resolverSchemaScope` to `GqlModuleOptions` via a patch on `@nestjs/graphql`, filtering in both `filterResolvers()` (runtime binding) and `getAllCtors()` (schema generation) - Each resolver is explicitly decorated with `@CoreResolver()` or `@MetadataResolver()` - Organized decorator, constant, and type files under `graphql-config/` following project conventions Core GQL Schema: (see: no more fields!) <img width="827" height="894" alt="image" src="https://github.com/user-attachments/assets/668f3f0f-485e-43f0-92be-4345aeccacb6" /> Metadata GQL Schema (see no more getTimelineCalendarEventsFromCompany) <img width="827" height="894" alt="image" src="https://github.com/user-attachments/assets/443913db-e5fe-4161-b0e7-4a971cc80a71" />
This commit is contained in:
+2
-2
@@ -3,9 +3,9 @@ import { useMutation } from '@apollo/client';
|
||||
import {
|
||||
type CreateWorkflowVersionEdgeMutation,
|
||||
type CreateWorkflowVersionEdgeMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
type CreateWorkflowVersionEdgeInput,
|
||||
} from '~/generated/graphql';
|
||||
import { CREATE_WORKFLOW_VERSION_EDGE } from '@/workflow/graphql/mutations/createWorkflowVersionEdge';
|
||||
import { type CreateWorkflowVersionEdgeInput } from '~/generated/graphql';
|
||||
import { useUpdateWorkflowVersionCache } from '@/workflow/workflow-steps/hooks/useUpdateWorkflowVersionCache';
|
||||
|
||||
export const useCreateWorkflowVersionEdge = () => {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
type CreateWorkflowVersionStepInput,
|
||||
type CreateWorkflowVersionStepMutation,
|
||||
type CreateWorkflowVersionStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
import { useUpdateWorkflowVersionCache } from '@/workflow/workflow-steps/hooks/useUpdateWorkflowVersionCache';
|
||||
import { flowComponentState } from '@/workflow/states/flowComponentState';
|
||||
import { useSetRecoilComponentState } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentState';
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { type CreateWorkflowVersionEdgeInput } from '~/generated/graphql';
|
||||
import { DELETE_WORKFLOW_VERSION_EDGE } from '@/workflow/graphql/mutations/deleteWorkflowVersionEdge';
|
||||
import {
|
||||
type CreateWorkflowVersionEdgeInput,
|
||||
type DeleteWorkflowVersionEdgeMutation,
|
||||
type DeleteWorkflowVersionEdgeMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
import { DELETE_WORKFLOW_VERSION_EDGE } from '@/workflow/graphql/mutations/deleteWorkflowVersionEdge';
|
||||
import { useUpdateWorkflowVersionCache } from '@/workflow/workflow-steps/hooks/useUpdateWorkflowVersionCache';
|
||||
|
||||
export const useDeleteWorkflowVersionEdge = () => {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
||||
type DeleteWorkflowVersionStepInput,
|
||||
type DeleteWorkflowVersionStepMutation,
|
||||
type DeleteWorkflowVersionStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useDeleteWorkflowVersionStep = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import {
|
||||
type DuplicateWorkflowVersionStepInput,
|
||||
type DuplicateWorkflowVersionStepMutation,
|
||||
type DuplicateWorkflowVersionStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useDuplicateWorkflowVersionStep = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import {
|
||||
type UpdateWorkflowRunStepInput,
|
||||
type UpdateWorkflowRunStepMutation,
|
||||
type UpdateWorkflowRunStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useUpdateWorkflowRunStep = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import {
|
||||
type UpdateWorkflowVersionStepInput,
|
||||
type UpdateWorkflowVersionStepMutation,
|
||||
type UpdateWorkflowVersionStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useUpdateWorkflowVersionStep = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
type SubmitFormStepInput,
|
||||
type SubmitFormStepMutation,
|
||||
type SubmitFormStepMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useSubmitFormStep = () => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import {
|
||||
type TestHttpRequestInput,
|
||||
type TestHttpRequestMutation,
|
||||
type TestHttpRequestMutationVariables,
|
||||
} from '~/generated-metadata/graphql';
|
||||
} from '~/generated/graphql';
|
||||
|
||||
const convertFlatVariablesToNestedContext = (flatVariables: {
|
||||
[variablePath: string]: any;
|
||||
|
||||
Reference in New Issue
Block a user