Fix GraphQL schema getting nuked on codemirror language refresh

This commit is contained in:
Gregory Schier
2025-07-21 14:17:36 -07:00
parent 7eb3f123c6
commit c609d0ff0c
4 changed files with 23 additions and 16 deletions

View File

@@ -37,6 +37,7 @@ import {
import { tags as t } from '@lezer/highlight';
import type { EnvironmentVariable } from '@yaakapp-internal/models';
import { graphql } from 'cm6-graphql';
import type { GraphQLSchema } from 'graphql';
import { activeRequestIdAtom } from '../../../hooks/useActiveRequestId';
import { jotaiStore } from '../../../lib/jotai';
import { renderMarkdown } from '../../../lib/markdown';
@@ -106,6 +107,7 @@ export function getLanguageExtension({
onClickMissingVariable,
onClickPathParameter,
completionOptions,
graphQLSchema,
}: {
useTemplating: boolean;
environmentVariables: EnvironmentVariable[];
@@ -113,6 +115,7 @@ export function getLanguageExtension({
onClickMissingVariable: (name: string, tagValue: string, startPos: number) => void;
onClickPathParameter: (name: string) => void;
completionOptions: TwigCompletionOption[];
graphQLSchema: GraphQLSchema | null;
} & Pick<EditorProps, 'language' | 'autocomplete'>) {
const extraExtensions: Extension[] = [];
@@ -128,7 +131,7 @@ export function getLanguageExtension({
// GraphQL is a special exception
if (language === 'graphql') {
return [
graphql(undefined, {
graphql(graphQLSchema ?? undefined, {
async onCompletionInfoRender(gqlCompletionItem): Promise<Node | null> {
if (!gqlCompletionItem.documentation) return null;
const innerHTML = await renderMarkdown(gqlCompletionItem.documentation);