Skip to content

Commit 98d13a3

Browse files
authored
extract doc-explorer plugin from @graphiql/react and publish as @graphiql/plugin-doc-explorer package (#3916)
* upd * graphiql-plugin-doc-explorer * graphiql-plugin-doc-explorer * rm * upd * upd * upd * upd * upd * upd * upd * use graphiql react * add todos * upd * add referencePlugin, schemaReference and setSchemaReference * onHasCompletion and useCompletion * upd * upd * upd * upd * prettier * use less diff * try to fix preview * fix unit tests * try another approach * ok, and now let's try .js instead of .cjs
1 parent c6fddac commit 98d13a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+420
-248
lines changed

.changeset/gentle-houses-add.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@graphiql/plugin-doc-explorer': patch
3+
'@graphiql/react': minor
4+
'graphiql': patch
5+
---
6+
7+
- remove the following exports from `@graphiql/react` and move them in `@graphiql/plugin-doc-explorer` package:
8+
- Argument
9+
- DefaultValue
10+
- DeprecationReason
11+
- Directive
12+
- DocExplorer
13+
- ExplorerContext
14+
- ExplorerContextProvider
15+
- ExplorerSection
16+
- FieldDocumentation
17+
- FieldLink
18+
- SchemaDocumentation
19+
- Search
20+
- TypeDocumentation
21+
- TypeLink
22+
- useExplorerContext
23+
- DOC_EXPLORER_PLUGIN
24+
- ExplorerContextType
25+
- ExplorerFieldDef
26+
- ExplorerNavStack
27+
- ExplorerNavStackItem
28+
29+
- add new `referencePlugin` prop on `PluginContextProviderProps` component for plugin which is used to display the reference documentation when selecting a type.

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ module.exports = {
358358
],
359359
'unicorn/no-length-as-slice-end': 'error',
360360
'unicorn/prefer-string-replace-all': 'error',
361+
'unicorn/prefer-array-some': 'error',
361362
'unicorn/no-hex-escape': 'off', // TODO: enable
362363
// doesn't catch a lot of cases; we use ESLint builtin `no-restricted-syntax` to forbid `.keyCode`
363364
'unicorn/prefer-keyboard-event-key': 'off',

functions/graphql.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
HandlerContext as NetlifyHandlerContext,
1111
} from '@netlify/functions';
1212

13-
import { schema } from '../packages/graphiql/test/schema.js';
13+
import { testSchema } from '../packages/graphiql/test/schema.js';
1414
import { customExecute } from '../packages/graphiql/test/execute.js';
1515

1616
/**
@@ -57,4 +57,7 @@ export function createHandler<Context extends OperationContext = undefined>(
5757
};
5858
}
5959

60-
export const handler = createHandler({ schema, execute: customExecute });
60+
export const handler = createHandler({
61+
schema: testSchema,
62+
execute: customExecute,
63+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# `@graphiql/plugin-doc-explorer`
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@graphiql/plugin-doc-explorer",
3+
"version": "0.0.0",
4+
"sideEffects": false,
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/graphql/graphiql",
8+
"directory": "packages/graphiql-plugin-doc-explorer"
9+
},
10+
"homepage": "https://github.com/graphql/graphiql/tree/master/packages/graphiql-plugin-doc-explorer#readme",
11+
"bugs": {
12+
"url": "https://github.com/graphql/graphiql/issues?q=issue+label:@graphiql/plugin-doc-explorer"
13+
},
14+
"license": "MIT",
15+
"exports": {
16+
"./package.json": "./package.json",
17+
"./style.css": "./dist/style.css",
18+
".": "./dist/index.js"
19+
},
20+
"types": "dist/index.d.ts",
21+
"keywords": [
22+
"react",
23+
"graphql",
24+
"graphiql",
25+
"plugin",
26+
"documentation",
27+
"explorer"
28+
],
29+
"files": [
30+
"dist"
31+
],
32+
"scripts": {
33+
"dev": "vite build --watch",
34+
"build": "vite build",
35+
"test": "vitest",
36+
"types:check": "tsc --noEmit"
37+
},
38+
"peerDependencies": {
39+
"react": "^18 || ^19",
40+
"react-dom": "^18 || ^19",
41+
"graphql": "^15.5.0 || ^16.0.0 || ^17.0.0"
42+
},
43+
"dependencies": {
44+
"react-compiler-runtime": "19.1.0-rc.1",
45+
"@graphiql/react": "^0.31.0",
46+
"@headlessui/react": "^2.2"
47+
},
48+
"devDependencies": {
49+
"@vitejs/plugin-react": "^4.4.1",
50+
"vite-plugin-dts": "^4.5.3",
51+
"babel-plugin-react-compiler": "19.1.0-rc.1",
52+
"@testing-library/dom": "^10.4.0",
53+
"@testing-library/jest-dom": "^6.6.3",
54+
"@testing-library/react": "^16.3.0",
55+
"react": "^19.1.0",
56+
"react-dom": "^19.1.0",
57+
"vite": "^6.3.4",
58+
"graphql": "^16.9.0"
59+
}
60+
}

packages/graphiql-react/src/explorer/components/__tests__/doc-explorer.spec.tsx renamed to packages/graphiql-plugin-doc-explorer/src/components/__tests__/doc-explorer.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render } from '@testing-library/react';
22
import { GraphQLInt, GraphQLObjectType, GraphQLSchema } from 'graphql';
33
import { useContext, useEffect } from 'react';
44

5-
import { SchemaContext, SchemaContextType } from '../../../schema';
5+
import { SchemaContext, SchemaContextType } from '@graphiql/react';
66
import { ExplorerContext, ExplorerContextProvider } from '../../context';
77
import { DocExplorer } from '../doc-explorer';
88

packages/graphiql-react/src/explorer/components/__tests__/type-documentation.spec.tsx renamed to packages/graphiql-plugin-doc-explorer/src/components/__tests__/type-documentation.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
GraphQLUnionType,
1111
} from 'graphql';
1212

13-
import { SchemaContext } from '../../../schema';
13+
import { SchemaContext } from '@graphiql/react';
1414
import { ExplorerContext } from '../../context';
1515
import { TypeDocumentation } from '../type-documentation';
1616
import { mockExplorerContextValue, unwrapType } from './test-utils';

0 commit comments

Comments
 (0)