Skip to content

show spinner in doc explorer based on isIntrospecting value, and not based on isFetching #4004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shy-keys-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/plugin-doc-explorer': patch
---

show spinner in doc explorer based on `isIntrospecting` value, and not based on `isFetching`
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ function makeSchema(fieldName = 'field') {
}

const defaultSchemaContext = {
fetchError: null,
introspect() {},
isFetching: false,
schema: makeSchema(),
validationErrors: [],
};
Expand All @@ -69,7 +67,7 @@ describe('DocExplorer', () => {

it('renders spinner when the schema is loading', () => {
useGraphiQL.mockImplementation(cb =>
cb({ ...defaultSchemaContext, isFetching: true }),
cb({ ...defaultSchemaContext, isIntrospecting: true }),
);
const { container } = render(<DocExplorerWithContext />);
const spinner = container.querySelectorAll('.graphiql-spinner');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { TypeDocumentation } from './type-documentation';
import './doc-explorer.css';

export const DocExplorer: FC = () => {
const { fetchError, isFetching, schema, validationErrors } = useGraphiQL(
pick('fetchError', 'isFetching', 'schema', 'validationErrors'),
const { fetchError, isIntrospecting, schema, validationErrors } = useGraphiQL(
pick('fetchError', 'isIntrospecting', 'schema', 'validationErrors'),
);
const explorerNavStack = useDocExplorer();
const { pop } = useDocExplorerActions();
Expand All @@ -27,7 +27,7 @@ export const DocExplorer: FC = () => {
Schema is invalid: {validationErrors[0].message}
</div>
);
} else if (isFetching) {
} else if (isIntrospecting) {
// Schema is undefined when it is being loaded via introspection.
content = <Spinner />;
} else if (!schema) {
Expand Down
Loading