Skip to content

Commit

Permalink
aa
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Dec 11, 2024
1 parent dae03ba commit e1b3cc5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/graphiql-react/src/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isSchema,
validateSchema,
} from 'graphql';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- unit tests fails without this useCallback
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react';

import { useEditorContext } from './editor';
Expand Down Expand Up @@ -152,6 +153,19 @@ export function SchemaContextProvider(props: SchemaContextProviderProps) {
}
});

/**
* Get introspection query for settings given via props
*/
const {
introspectionQuery,
introspectionQueryName,
introspectionQuerySansSubscriptions,
} = useIntrospectionQuery({
inputValueDeprecation: props.inputValueDeprecation,
introspectionQueryName: props.introspectionQueryName,
schemaDescription: props.schemaDescription,
});

/**
* Fetch the schema
*/
Expand All @@ -165,19 +179,6 @@ export function SchemaContextProvider(props: SchemaContextProviderProps) {
return;
}

/**
* Get introspection query for settings given via props
*/
const {
introspectionQuery,
introspectionQueryName,
introspectionQuerySansSubscriptions,
} = useIntrospectionQuery({
inputValueDeprecation: props.inputValueDeprecation,
introspectionQueryName: props.introspectionQueryName,
schemaDescription: props.schemaDescription,
});

const counter = ++counterRef.current;

const maybeIntrospectionData = props.schema;
Expand Down Expand Up @@ -297,7 +298,7 @@ export function SchemaContextProvider(props: SchemaContextProviderProps) {
* Trigger introspection automatically
*/
useEffect(() => {
introspect();
void introspect();
}, [introspect]);

/**
Expand All @@ -306,7 +307,7 @@ export function SchemaContextProvider(props: SchemaContextProviderProps) {
useEffect(() => {
function triggerIntrospection(event: KeyboardEvent) {
if (event.ctrlKey && event.key === 'R') {
introspect();
void introspect();

Check warning on line 310 in packages/graphiql-react/src/schema.tsx

View check run for this annotation

Codecov / codecov/patch

packages/graphiql-react/src/schema.tsx#L310

Added line #L310 was not covered by tests
}
}

Expand Down

0 comments on commit e1b3cc5

Please sign in to comment.