@graphiql/plugin-doc-explorer 1.0.0-rc.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/argument.js +3 -4
- package/dist/components/argument.js.map +1 -1
- package/dist/components/arguments-list.js +66 -69
- package/dist/components/arguments-list.js.map +1 -1
- package/dist/components/breadcrumb.js +2 -3
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/default-value.d.ts +8 -0
- package/dist/components/default-value.js +38 -28
- package/dist/components/default-value.js.map +1 -1
- package/dist/components/deprecation-reason.js +2 -3
- package/dist/components/deprecation-reason.js.map +1 -1
- package/dist/components/directive.js +2 -3
- package/dist/components/directive.js.map +1 -1
- package/dist/components/doc-explorer.js +4 -5
- package/dist/components/doc-explorer.js.map +1 -1
- package/dist/components/field-card.js +4 -5
- package/dist/components/field-card.js.map +1 -1
- package/dist/components/field-documentation.js +3 -4
- package/dist/components/field-documentation.js.map +1 -1
- package/dist/components/field-link.js +2 -3
- package/dist/components/field-link.js.map +1 -1
- package/dist/components/fields-list.js +6 -7
- package/dist/components/fields-list.js.map +1 -1
- package/dist/components/schema-documentation.js +4 -5
- package/dist/components/schema-documentation.js.map +1 -1
- package/dist/components/search-row.js +7 -8
- package/dist/components/search-row.js.map +1 -1
- package/dist/components/search.js +6 -7
- package/dist/components/search.js.map +1 -1
- package/dist/components/section.js +2 -3
- package/dist/components/section.js.map +1 -1
- package/dist/components/type-card.js +3 -4
- package/dist/components/type-card.js.map +1 -1
- package/dist/components/type-documentation.js +7 -8
- package/dist/components/type-documentation.js.map +1 -1
- package/dist/components/type-link.js +3 -4
- package/dist/components/type-link.js.map +1 -1
- package/dist/components/utils.js +1 -2
- package/dist/components/utils.js.map +1 -1
- package/dist/context.js +5 -6
- package/dist/context.js.map +1 -1
- package/dist/schema-reference.js +1 -2
- package/dist/schema-reference.js.map +1 -1
- package/dist/style.css +12 -12
- package/package.json +17 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-card.js","names":["
|
|
1
|
+
{"version":3,"file":"type-card.js","names":["isObjectType","isInterfaceType","isInputObjectType","isEnumType","isScalarType","isUnionType","useDocExplorerActions","getTypeKind","type","TypeCard","t0","$","_c","push","t1","kind","t2","interfaces","getInterfaces","t3","t4","name","t5","t6","description","length","map","iface","i","event","preventDefault","def","_jsx","_jsxs"],"sources":["../../src/components/type-card.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport {\n GraphQLNamedType,\n isObjectType,\n isInterfaceType,\n isInputObjectType,\n isEnumType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { useDocExplorerActions } from '../context';\nimport './type-card.css';\n\nfunction getTypeKind(type: GraphQLNamedType): string {\n if (isObjectType(type)) {\n return 'TYPE';\n }\n if (isInterfaceType(type)) {\n return 'INTERFACE';\n }\n if (isInputObjectType(type)) {\n return 'INPUT';\n }\n if (isEnumType(type)) {\n return 'ENUM';\n }\n if (isScalarType(type)) {\n return 'SCALAR';\n }\n if (isUnionType(type)) {\n return 'UNION';\n }\n return 'TYPE';\n}\n\ntype TypeCardProps = {\n type: GraphQLNamedType;\n};\n\nexport const TypeCard: FC<TypeCardProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n const kind = getTypeKind(type);\n const interfaces = isObjectType(type) ? type.getInterfaces() : [];\n\n return (\n <div className=\"graphiql-doc-explorer-type-card\">\n <div className=\"graphiql-doc-explorer-type-card-header\">\n <span className=\"graphiql-doc-explorer-type-badge\">{kind}</span>\n <span className=\"graphiql-doc-explorer-type-card-name\">\n {type.name}\n </span>\n </div>\n {type.description && (\n <p className=\"graphiql-doc-explorer-type-card-description\">\n {type.description}\n </p>\n )}\n {interfaces.length > 0 && (\n <div className=\"graphiql-doc-explorer-type-card-implements\">\n <span className=\"graphiql-doc-explorer-type-card-implements-keyword\">\n implements\n </span>\n {interfaces.map((iface, i) => (\n <span\n key={iface.name}\n className=\"graphiql-doc-explorer-type-card-implements-item\"\n >\n {i > 0 && (\n <span\n className=\"graphiql-doc-explorer-type-card-implements-dot\"\n aria-hidden=\"true\"\n >\n ·\n </span>\n )}\n <a\n href=\"#\"\n className=\"graphiql-doc-explorer-type-card-implements-link\"\n onClick={event => {\n event.preventDefault();\n push({ name: iface.name, def: iface });\n }}\n >\n {iface.name}\n </a>\n </span>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;AAaA,SAASO,YAAYC,MAAgC;CACnD,IAAIR,aAAaQ,IAAI,GACnB,OAAO;CAET,IAAIP,gBAAgBO,IAAI,GACtB,OAAO;CAET,IAAIN,kBAAkBM,IAAI,GACxB,OAAO;CAET,IAAIL,WAAWK,IAAI,GACjB,OAAO;CAET,IAAIJ,aAAaI,IAAI,GACnB,OAAO;CAET,IAAIH,YAAYG,IAAI,GAClB,OAAO;CAET,OAAO;AACT;AAMA,IAAaC,YAA8BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAJ,SAAAE;CAC1C,MAAA,EAAAG,SAAiBP,sBAAsB;CAAE,IAAAQ;CAAA,IAAAH,EAAA,OAAAH,MAAA;EAC5BM,KAAAP,YAAYC,IAAI;EAACG,EAAA,KAAAH;EAAAG,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAA9B,MAAAI,OAAaD;CAAkB,IAAAE;CAAA,IAAAL,EAAA,OAAAI,QAAAJ,EAAA,OAAAE,QAAAF,EAAA,OAAAH,MAAA;EAC/B,MAAAS,aAAmBjB,aAAaQ,IAAgC,IAAxBA,KAAIU,cAAoB,IAA7C,CAAA;EAA+C,IAAAC;EAAA,IAAAR,EAAA,OAAAI,MAAA;GAK5DI,KAAAa,oBAAA,QAAA;IAAgB,WAAA;IAAoCjB,UAAAA;GAAW,CAAA;GAACJ,EAAA,KAAAI;GAAAJ,EAAA,KAAAQ;EAAA,OAAAA,KAAAR,EAAA;EAAA,IAAAS;EAAA,IAAAT,EAAA,OAAAH,KAAAa,MAAA;GAChED,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EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OA5CNK;AA4CM"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { isAbstractType, isEnumType, isInputObjectType, isInterfaceType, isNamedType, isObjectType } from "graphql";
|
|
4
|
+
import { Button, MarkdownContent, useGraphiQL } from "@graphiql/react";
|
|
3
5
|
import { Argument } from "./argument.js";
|
|
6
|
+
import { DefaultValue } from "./default-value.js";
|
|
4
7
|
import { DeprecationReason } from "./deprecation-reason.js";
|
|
5
8
|
import { FieldLink } from "./field-link.js";
|
|
6
9
|
import { ExplorerSection } from "./section.js";
|
|
10
|
+
import { TypeLink } from "./type-link.js";
|
|
7
11
|
/* empty css */
|
|
8
|
-
import { c } from "react-compiler-runtime";
|
|
9
|
-
import { Button, MarkdownContent, useGraphiQL } from "@graphiql/react";
|
|
10
|
-
import { isAbstractType, isEnumType, isInputObjectType, isInterfaceType, isNamedType, isObjectType } from "graphql";
|
|
11
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
|
|
13
|
-
//#region src/components/type-documentation.tsx
|
|
13
|
+
// src/components/type-documentation.tsx
|
|
14
14
|
var TypeDocumentation = (t0) => {
|
|
15
15
|
const $ = c(3);
|
|
16
16
|
const { type, hideHeader } = t0;
|
|
@@ -362,7 +362,6 @@ function _temp7(state) {
|
|
|
362
362
|
function _temp8(possibleType) {
|
|
363
363
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TypeLink, { type: possibleType }) }, possibleType.name);
|
|
364
364
|
}
|
|
365
|
-
//#endregion
|
|
366
365
|
export { TypeDocumentation };
|
|
367
366
|
|
|
368
367
|
//# sourceMappingURL=type-documentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-documentation.js","names":["FC","useState","GraphQLEnumValue","GraphQLNamedType","isAbstractType","isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","useGraphiQL","Button","MarkdownContent","DocExplorerFieldDef","Argument","DefaultValue","DeprecationReason","FieldLink","ExplorerSection","TypeLink","TypeDocumentationProps","type","hideHeader","TypeDocumentation","t0","$","_c","t1","description","ImplementsInterfaces","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","Symbol","for","handleShowDeprecated","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","schema","_temp7","getPossibleTypes","_temp8","implementedInterface","field_0","field_1","value_0","value_1","state","possibleType"],"sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useGraphiQL, Button, MarkdownContent } from '@graphiql/react';\nimport type { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n /**\n * When true, the description, implements-interfaces, and fields sections\n * are omitted. Used when TypeCard + FieldsList are already rendering those\n * above the type documentation.\n */\n hideHeader?: boolean;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({\n type,\n hideHeader,\n}) => {\n return isNamedType(type) ? (\n <>\n {!hideHeader && type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n {!hideHeader && <ImplementsInterfaces type={type} />}\n {!hideHeader && <Fields type={type} />}\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n // TODO: maybe can be refactored to Object.values(fieldMap) ?\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name]!)) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 && (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n )}\n {deprecatedValues.length > 0 &&\n (showDeprecated || !values.length ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n ))}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description && (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n )}\n {value.deprecationReason && (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n )}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const schema = useGraphiQL(state => state.schema);\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkCA,IAAauB,qBAAgDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAL,MAAAC,eAAAE;CAG7D,IAAAG;CAAA,IAAAF,EAAA,OAAAH,cAAAG,EAAA,OAAAJ,MAAA;EACQM,KAAAnB,YAAYa,IAUZ,IAVA,qBAAA,UAAA,EAAA,UAAA;GAEF,CAACC,cAAcD,KAAIO,cAClB,oBAAC,iBAAD;IAAsB,MAAA;IAAeP,UAAAA,KAAIO;GAAzB,CAAA,IADjB;GAGA,CAACN,cAAc,oBAAC,sBAAD,EAA4BD,KAAI,CAAA;GAC/C,CAACC,cAAc,oBAAC,QAAD,EAAcD,KAAI,CAAA;GAClC,oBAAC,YAAD,EAAkBA,KAAI,CAAA;GACtB,oBAAC,eAAD,EAAqBA,KAAI,CAAA;EAAI,EAAA,CAAA,IAR1B;EAUCI,EAAA,KAAAH;EAAAG,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAVDE;AAUC;AAGV,IAAME,wBAAuDL,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAL,SAAAG;CAC5D,IAAI,CAACf,aAAaY,IAAI,GAAC,OACd;CACR,IAAAM;CAAA,IAAAF,EAAA,OAAAJ,MAAA;EACkBM,KAAAN,KAAIS,cAAe;EAACL,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAvC,MAAAM,aAAmBJ;CAAqB,IAAAK;CAAA,IAAAP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,EACxB,GAFIA,aAAYrC,IAEhB;AAAA"}
|
|
1
|
+
{"version":3,"file":"type-documentation.js","names":["useState","isAbstractType","isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","useGraphiQL","type","hideHeader","TypeDocumentation","t0","$","_c","t1","description","ImplementsInterfaces","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","Symbol","for","handleShowDeprecated","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","schema","_temp7","getPossibleTypes","_temp8","implementedInterface","field_0","field_1","value_0","value_1","state","possibleType","_jsxs","_Fragment","_jsx"],"sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useGraphiQL, Button, MarkdownContent } from '@graphiql/react';\nimport type { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n /**\n * When true, the description, implements-interfaces, and fields sections\n * are omitted. Used when TypeCard + FieldsList are already rendering those\n * above the type documentation.\n */\n hideHeader?: boolean;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({\n type,\n hideHeader,\n}) => {\n return isNamedType(type) ? (\n <>\n {!hideHeader && type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n {!hideHeader && <ImplementsInterfaces type={type} />}\n {!hideHeader && <Fields type={type} />}\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n // TODO: maybe can be refactored to Object.values(fieldMap) ?\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name]!)) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 && (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n )}\n {deprecatedValues.length > 0 &&\n (showDeprecated || !values.length ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n ))}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description && (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n )}\n {value.deprecationReason && (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n )}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const schema = useGraphiQL(state => state.schema);\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkCA,IAAaU,qBAAgDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAL,MAAAC,eAAAE;CAG7D,IAAAG;CAAA,IAAAF,EAAA,OAAAH,cAAAG,EAAA,OAAAJ,MAAA;EACQM,KAAAT,YAAYG,IAUZ,IAVAkE,qBAAAC,UAAA,EAAA,UAAA;GAEF,CAAClE,cAAcD,KAAIO,cAClB6D,oBAAC,iBAAD;IAAsB,MAAA;IAAepE,UAAAA,KAAIO;GAA8B,CAAA,IADxE;GAGA,CAACN,cAAcmE,oBAAC,sBAAD,EAA4BpE,KAAM,CAAA;GACjD,CAACC,cAAcmE,oBAAC,QAAD,EAAcpE,KAAM,CAAA;GACpCoE,oBAAC,YAAD,EAAkBpE,KAAM,CAAA;GACxBoE,oBAAC,eAAD,EAAqBpE,KAAM,CAAA;EAAE,EAAA,CAAA,IAR1B;EAUCI,EAAA,KAAAH;EAAAG,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAVDE;AAUC;AAGV,IAAME,wBAAuDL,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAL,SAAAG;CAC5D,IAAI,CAACL,aAAaE,IAAI,GAAC,OACd;CACR,IAAAM;CAAA,IAAAF,EAAA,OAAAJ,MAAA;EACkBM,KAAAN,KAAIS,cAAe;EAACL,EAAA,KAAAJ;EAAAI,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAvC,MAAAM,aAAmBJ;CAAqB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AAA;CAAA,OAU9CG,oBAAA,OAAA,EAAA,UACEA,oBAAC,UAAD,EAAgBH,MAAAA,aAAc,CAAA,EAC3B,GAFKA,aAAYrC,IAEjB;AAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
|
+
import { typeCategory } from "@graphiql/react";
|
|
1
3
|
import { useDocExplorerActions } from "../context.js";
|
|
2
4
|
import { renderType } from "./utils.js";
|
|
3
5
|
/* empty css */
|
|
4
|
-
import { c } from "react-compiler-runtime";
|
|
5
|
-
import { typeCategory } from "@graphiql/react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/type-link.tsx
|
|
8
8
|
var TypeLink = (t0) => {
|
|
9
9
|
const $ = c(5);
|
|
10
10
|
const { type } = t0;
|
|
@@ -36,7 +36,6 @@ var TypeLink = (t0) => {
|
|
|
36
36
|
} else t2 = $[4];
|
|
37
37
|
return t2;
|
|
38
38
|
};
|
|
39
|
-
//#endregion
|
|
40
39
|
export { TypeLink };
|
|
41
40
|
|
|
42
41
|
//# sourceMappingURL=type-link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-link.js","names":["
|
|
1
|
+
{"version":3,"file":"type-link.js","names":["typeCategory","useDocExplorerActions","renderType","type","TypeLink","t0","$","_c","push","t1","def","event","preventDefault","name","t2","_jsx"],"sources":["../../src/components/type-link.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport type { GraphQLType } from 'graphql';\nimport { typeCategory } from '@graphiql/react';\nimport { useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n\n return renderType(type, def => (\n <a\n className=\"graphiql-doc-explorer-type-name\"\n data-type-kind={typeCategory(def)}\n onClick={event => {\n event.preventDefault();\n push({ name: def.name, def });\n }}\n href=\"#\"\n >\n {def.name}\n </a>\n ));\n};\n"],"mappings":";;;;;;;AAcA,IAAaI,YAA8BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAJ,SAAAE;CAC1C,MAAA,EAAAG,SAAiBP,sBAAsB;CAAE,IAAAQ;CAAA,IAAAH,EAAA,OAAAE,MAAA;EAEjBC,MAAAC,QACtBK,oBAAA,KAAA;GACY,WAAA;GACM,kBAAAf,aAAaU,GAAG;GACvB,UAAAC,UAAA;IACPA,MAAKC,eAAgB;IACrBJ,KAAK;KAAAK,MAAQH,IAAGG;KAAKH;IAAM,CAAC;GAAC;GAE1B,MAAA;GAEJA,UAAAA,IAAGG;EACH,CAAA;EACJP,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAG,MAAAH,EAAA,OAAAH,MAAA;EAZMW,KAAAZ,WAAWC,MAAMM,EAYvB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAH;EAAAG,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAZKQ;AAYL"}
|
package/dist/components/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use no memo";
|
|
2
2
|
import { isListType, isNonNullType } from "graphql";
|
|
3
3
|
import { Fragment, jsxs } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/utils.tsx
|
|
5
5
|
function renderType(type, renderNamedType) {
|
|
6
6
|
if (isNonNullType(type)) return /* @__PURE__ */ jsxs(Fragment, { children: [renderType(type.ofType, renderNamedType), "!"] });
|
|
7
7
|
if (isListType(type)) return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -11,7 +11,6 @@ function renderType(type, renderNamedType) {
|
|
|
11
11
|
] });
|
|
12
12
|
return renderNamedType(type);
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { renderType };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["isListType","isNonNullType","renderType","type","renderNamedType","ofType","_jsxs","_Fragment"],"sources":["../../src/components/utils.tsx"],"sourcesContent":["'use no memo';\n\nimport {\n GraphQLNamedType,\n GraphQLType,\n isListType,\n isNonNullType,\n} from 'graphql';\nimport type { JSX } from 'react';\n\nexport function renderType(\n type: GraphQLType,\n renderNamedType: (namedType: GraphQLNamedType) => JSX.Element,\n): JSX.Element {\n if (isNonNullType(type)) {\n return <>{renderType(type.ofType, renderNamedType)}!</>;\n }\n if (isListType(type)) {\n return <>[{renderType(type.ofType, renderNamedType)}]</>;\n }\n return renderNamedType(type);\n}\n"],"mappings":";;;;AAUA,SAAgBE,WACdC,MACAC,iBACa;CACb,IAAIH,cAAcE,IAAI,GACpB,OAAOG,qBAAAC,UAAA,EAAA,UAAA,CAAGL,WAAWC,KAAKE,QAAQD,eAAe,GAAE,GAAG,EAAA,CAAA;CAExD,IAAIJ,WAAWG,IAAI,GACjB,OAAOG,qBAAAC,UAAA,EAAA,UAAA;EAAE;EAAEL,WAAWC,KAAKE,QAAQD,eAAe;EAAE;CAAG,EAAA,CAAA;CAEzD,OAAOA,gBAAgBD,IAAI;AAC7B"}
|
package/dist/context.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getSchemaReference } from "./schema-reference.js";
|
|
2
|
-
import { DocExplorer } from "./components/doc-explorer.js";
|
|
3
1
|
import { c } from "react-compiler-runtime";
|
|
4
|
-
import { DocsFilledIcon, DocsIcon, createBoundedUseStore, isMacOs, pick, useGraphiQL, useGraphiQLActions } from "@graphiql/react";
|
|
5
2
|
import { isEnumType, isInputObjectType, isInterfaceType, isNamedType, isObjectType, isScalarType, isUnionType } from "graphql";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
3
|
import { useEffect } from "react";
|
|
4
|
+
import { DocsFilledIcon, DocsIcon, createBoundedUseStore, isMacOs, pick, useGraphiQL, useGraphiQLActions } from "@graphiql/react";
|
|
8
5
|
import { createStore } from "zustand";
|
|
9
|
-
|
|
6
|
+
import { getSchemaReference } from "./schema-reference.js";
|
|
7
|
+
import { DocExplorer } from "./components/doc-explorer.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
// src/context.tsx
|
|
10
10
|
var DOC_EXPLORER_PLUGIN = {
|
|
11
11
|
title: "Documentation Explorer",
|
|
12
12
|
icon: function Icon() {
|
|
@@ -213,7 +213,6 @@ function _temp(state) {
|
|
|
213
213
|
function _temp2(state) {
|
|
214
214
|
return state.actions;
|
|
215
215
|
}
|
|
216
|
-
//#endregion
|
|
217
216
|
export { DOC_EXPLORER_PLUGIN, DocExplorerStore, docExplorerStore, useDocExplorer, useDocExplorerActions };
|
|
218
217
|
|
|
219
218
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["GraphQLArgument","GraphQLField","GraphQLInputField","GraphQLNamedType","GraphQLSchema","isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","isScalarType","isUnionType","FC","ReactElement","ReactNode","useEffect","SchemaReference","useGraphiQL","useGraphiQLActions","pick","createBoundedUseStore","GraphiQLPlugin","DocsFilledIcon","DocsIcon","isMacOs","createStore","getSchemaReference","DocExplorer","DOC_EXPLORER_PLUGIN","title","icon","Icon","visiblePlugin","state","content","DocExplorerFieldDef","DocExplorerNavStackItem","name","def","DocExplorerNavStack","DocExplorerStoreType","explorerNavStack","actions","push","item","pop","reset","resolveSchemaReferenceToNavItem","schemaReference","rebuildNavStackWithSchema","schema","INITIAL_NAV_STACK","docExplorerStore","set","curr","lastItem","at","length","slice","kind","typeInfo","ref","items","type","field","oldNavStack","newNavStack","lastEntity","newType","getType","getFields","args","some","a","focusSearchInputWhenMounted","framesLeft","requestAnimationFrame","el","document","querySelector","HTMLDivElement","click","DocExplorerStore","children","t0","$","_c","t1","Symbol","for","validationErrors","setVisiblePlugin","t2","t3","getState","t4","t5","t6","t7","handleKeyDown","event","shouldOpenSearch","code","preventDefault","stopPropagation","window","addEventListener","removeEventListener","useDocExplorerStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport {\n SchemaReference,\n useGraphiQL,\n useGraphiQLActions,\n pick,\n createBoundedUseStore,\n GraphiQLPlugin,\n DocsFilledIcon,\n DocsIcon,\n isMacOs,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\nimport { DocExplorer } from './components';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const visiblePlugin = useGraphiQL(state => state.visiblePlugin);\n return visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerStoreType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: DocExplorerNavStack;\n actions: {\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: DocExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n resolveSchemaReferenceToNavItem(\n schemaReference: SchemaReference | null,\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Root' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(set => ({\n explorerNavStack: INITIAL_NAV_STACK,\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n // Replace the current path with the path to the referenced item,\n // rather than appending to it; repeatedly clicking the same reference\n // must not grow the stack.\n const items: DocExplorerNavStackItem[] = [];\n switch (ref.kind) {\n case 'Type': {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n // Show a field type on stack\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n break;\n }\n }\n if (items.length > 0) {\n set({ explorerNavStack: [INITIAL_NAV_STACK[0], ...items] });\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return { explorerNavStack: newNavStack };\n });\n },\n },\n}));\n\n// The doc-explorer panel (and its search input) mounts asynchronously after\n// `setVisiblePlugin` commits, which isn't guaranteed to land within a single\n// animation frame, so poll across a few frames rather than assuming one is\n// enough.\nfunction focusSearchInputWhenMounted(framesLeft: number) {\n if (framesLeft <= 0) {\n return;\n }\n requestAnimationFrame(() => {\n const el = document.querySelector<HTMLDivElement>(\n '.graphiql-doc-explorer-search-row-input',\n );\n if (el) {\n el.click();\n } else {\n focusSearchInputWhenMounted(framesLeft - 1);\n }\n });\n}\n\nexport const DocExplorerStore: FC<{\n children: ReactNode;\n}> = ({ children }) => {\n const { schema, validationErrors, schemaReference } = useGraphiQL(\n pick('schema', 'validationErrors', 'schemaReference'),\n );\n const { setVisiblePlugin } = useGraphiQLActions();\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n useEffect(() => {\n function handleKeyDown(event: KeyboardEvent) {\n const shouldOpenSearch =\n event[isMacOs ? 'metaKey' : 'ctrlKey'] &&\n // Using `event.code` because `event.key` will trigger different character\n // in English `˚` and in French `È`\n event.code === 'KeyK';\n if (!shouldOpenSearch) {\n return;\n }\n // Take priority over monaco-editor's built-in `Cmd/Ctrl+K` binding even\n // when an editor pane has focus.\n event.preventDefault();\n event.stopPropagation();\n\n setVisiblePlugin(DOC_EXPLORER_PLUGIN);\n // The panel (and its search input) mounts after this state update\n // commits, which isn't guaranteed to land within a single animation\n // frame, so poll across a few frames rather than assuming one is enough.\n focusSearchInputWhenMounted(10);\n }\n\n window.addEventListener('keydown', handleKeyDown, true);\n return () => {\n window.removeEventListener('keydown', handleKeyDown, true);\n };\n }, [setVisiblePlugin]);\n\n return children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\n\n/**\n * Actions are functions used to update values in your store. They are static and never change.\n * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state\n */\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"mappings":";;;;;;;;;AAgCA,IAAa4B,sBAAsC;CACjDC,OAAO;CACPC,MAAM,SAASC,OAAO;EAEpB,OADsBd,aAAYgB,UAASA,MAAMD,aAC1CA,MAAkBJ,sBACvB,oBAAC,gBAAD,CAAe,CAAA,IAEf,oBAAC,UAAD,CAAS,CAAA;CAEb;CACAM,SAASP;AACX;AAwDA,IAAMwB,oBAAyC,CAAC,EAAEd,MAAM,OAAO,CAAC;AAEhE,IAAae,mBAAmB3B,aAAkC4B,SAAQ;CACxEZ,kBAAkBU;CAClBT,SAAS;EACPC,KAAKC,MAAM;GACTS,KAAIpB,UAAS;IACX,MAAMqB,OAAOrB,MAAMQ;IAMnB,OAAO,EAAEA,kBALQa,KAAKE,GAAG,EAGvBD,CAAAA,CAASjB,QAAQM,KAAKN,MAAMgB,OAAO,CAAC,GAAGA,MAAMV,IAAI,EAEzB;GAC5B,CAAC;EACH;EACAC,MAAM;GACJQ,KAAIpB,UAAS;IACX,MAAMqB,OAAOrB,MAAMQ;IAKnB,OAAO,EAAEA,kBAFPa,KAAKG,SAAS,IAAKH,KAAKI,MAAM,GAAG,EAAE,IAA4BJ,KAEvC;GAC5B,CAAC;EACH;EACAR,QAAQ;GACNO,KAAIpB,UAAS;IACX,MAA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B/D,mBAAmB;IAIpC8C,4BAA4B,EAAE;GAAC;GAGjC+B,OAAMC,iBAAkB,WAAWP,eAAe,IAAI;GAAC,aAChD;IACLM,OAAME,oBAAqB,WAAWR,eAAe,IAAI;GAAC;EAC3D;EACAD,KAAA,CAACP,gBAAgB;EAACN,EAAA,KAAAM;EAAAN,EAAA,KAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAD,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CA1BrBtE,UAAUkF,IA0BPC,EAAkB;CAAC,OAEff;AAAwB;AAGjC,IAAMyB,sBAAsBxF,sBAAsBgC,gBAAgB;AAElE,IAAayD,uBAAiB;CAAA,OAC5BD,oBAAoBE,KAA+B;AAAC;;;;;AAMtD,IAAaC,8BAAwB;CAAA,OACnCH,oBAAoBI,MAAsB;AAAC;AARf,SAAAF,MAAA7E,OAAA;CAAA,OACCA,MAAKQ;AAAiB;AAMhB,SAAAuE,OAAA/E,OAAA;CAAA,OACNA,MAAKS;AAAQ"}
|
|
1
|
+
{"version":3,"file":"context.js","names":["isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","isScalarType","isUnionType","useEffect","useGraphiQL","useGraphiQLActions","pick","createBoundedUseStore","isMacOs","createStore","getSchemaReference","DocExplorer","DOC_EXPLORER_PLUGIN","title","icon","Icon","visiblePlugin","state","content","name","def","explorerNavStack","actions","push","item","pop","reset","resolveSchemaReferenceToNavItem","schemaReference","rebuildNavStackWithSchema","schema","INITIAL_NAV_STACK","docExplorerStore","set","curr","lastItem","at","length","slice","kind","typeInfo","ref","items","type","field","oldNavStack","newNavStack","lastEntity","newType","getType","getFields","args","some","a","focusSearchInputWhenMounted","framesLeft","requestAnimationFrame","el","document","querySelector","click","DocExplorerStore","children","t0","$","_c","t1","Symbol","for","validationErrors","setVisiblePlugin","t2","t3","getState","t4","t5","t6","t7","handleKeyDown","event","code","preventDefault","stopPropagation","window","addEventListener","removeEventListener","useDocExplorerStore","useDocExplorer","_temp","useDocExplorerActions","_temp2","_jsx"],"sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport {\n SchemaReference,\n useGraphiQL,\n useGraphiQLActions,\n pick,\n createBoundedUseStore,\n GraphiQLPlugin,\n DocsFilledIcon,\n DocsIcon,\n isMacOs,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\nimport { DocExplorer } from './components';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const visiblePlugin = useGraphiQL(state => state.visiblePlugin);\n return visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerStoreType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: DocExplorerNavStack;\n actions: {\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: DocExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n resolveSchemaReferenceToNavItem(\n schemaReference: SchemaReference | null,\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Root' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(set => ({\n explorerNavStack: INITIAL_NAV_STACK,\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n // Replace the current path with the path to the referenced item,\n // rather than appending to it; repeatedly clicking the same reference\n // must not grow the stack.\n const items: DocExplorerNavStackItem[] = [];\n switch (ref.kind) {\n case 'Type': {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n // Show a field type on stack\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n break;\n }\n }\n if (items.length > 0) {\n set({ explorerNavStack: [INITIAL_NAV_STACK[0], ...items] });\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return { explorerNavStack: newNavStack };\n });\n },\n },\n}));\n\n// The doc-explorer panel (and its search input) mounts asynchronously after\n// `setVisiblePlugin` commits, which isn't guaranteed to land within a single\n// animation frame, so poll across a few frames rather than assuming one is\n// enough.\nfunction focusSearchInputWhenMounted(framesLeft: number) {\n if (framesLeft <= 0) {\n return;\n }\n requestAnimationFrame(() => {\n const el = document.querySelector<HTMLDivElement>(\n '.graphiql-doc-explorer-search-row-input',\n );\n if (el) {\n el.click();\n } else {\n focusSearchInputWhenMounted(framesLeft - 1);\n }\n });\n}\n\nexport const DocExplorerStore: FC<{\n children: ReactNode;\n}> = ({ children }) => {\n const { schema, validationErrors, schemaReference } = useGraphiQL(\n pick('schema', 'validationErrors', 'schemaReference'),\n );\n const { setVisiblePlugin } = useGraphiQLActions();\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n useEffect(() => {\n function handleKeyDown(event: KeyboardEvent) {\n const shouldOpenSearch =\n event[isMacOs ? 'metaKey' : 'ctrlKey'] &&\n // Using `event.code` because `event.key` will trigger different character\n // in English `˚` and in French `È`\n event.code === 'KeyK';\n if (!shouldOpenSearch) {\n return;\n }\n // Take priority over monaco-editor's built-in `Cmd/Ctrl+K` binding even\n // when an editor pane has focus.\n event.preventDefault();\n event.stopPropagation();\n\n setVisiblePlugin(DOC_EXPLORER_PLUGIN);\n // The panel (and its search input) mounts after this state update\n // commits, which isn't guaranteed to land within a single animation\n // frame, so poll across a few frames rather than assuming one is enough.\n focusSearchInputWhenMounted(10);\n }\n\n window.addEventListener('keydown', handleKeyDown, true);\n return () => {\n window.removeEventListener('keydown', handleKeyDown, true);\n };\n }, [setVisiblePlugin]);\n\n return children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\n\n/**\n * Actions are functions used to update values in your store. They are static and never change.\n * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state\n */\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"mappings":";;;;;;;;;AAgCA,IAAagB,sBAAsC;CACjDC,OAAO;CACPC,MAAM,SAASC,OAAO;EAEpB,OADsBX,aAAYa,UAASA,MAAMD,aAC1CA,MAAkBJ,sBACvB+E,oBAAC,gBAAD,CAAgB,CAAA,IAEhBA,oBAAC,UAAD,CAAU,CAAA;CAEd;CACAzE,SAASP;AACX;AAwDA,IAAMoB,oBAAyC,CAAC,EAAEZ,MAAM,OAAO,CAAC;AAEhE,IAAaa,mBAAmBvB,aAAkCwB,SAAQ;CACxEZ,kBAAkBU;CAClBT,SAAS;EACPC,KAAKC,MAAM;GACTS,KAAIhB,UAAS;IACX,MAAMiB,OAAOjB,MAAMI;IAMnB,OAAO,EAAEA,kBALQa,KAAKE,GAAG,EAGvBD,CAAAA,CAASf,QAAQI,KAAKJ,MAAMc,OAAO,CAAC,GAAGA,MAAMV,IAAI,EAEzB;GAC5B,CAAC;EACH;EACAC,MAAM;GACJQ,KAAIhB,UAAS;IACX,MAAMiB,OAAOjB,MAAMI;IAKnB,OAAO,EAAEA,kBAFPa,KAAKG,SAAS,IAAKH,KAAKI,MAAM,GAAG,EAAE,IAA4BJ,KAEvC;GAC5B,CAAC;EACH;EACAR,QAAQ;GACNO,KAAIhB,UAAS;IACX,MAAMiB,OAAOjB,MAAMI;IAEnB,OAAO,EAAEA,kBADgBa,KAAKG,WAAW,IAAIH,OAAOH,kBAC1B;GAC5B,CAAC;EACH;EACAJ,gCAAgCC,iBAAiB;GAC/C,IAAI,CAACA,iBACH;GAEF,MAAM,EAAEW,MAAMC,aAAaZ;GAC3B,MAAMa,MAAM/B,mBAAmB6B,MAAM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KAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAD,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CA1BrB7D,UAAUyE,IA0BPC,EAAkB;CAAC,OAEff;AAAwB;AAGjC,IAAMwB,sBAAsB/E,sBAAsByB,gBAAgB;AAElE,IAAauD,uBAAiB;CAAA,OAC5BD,oBAAoBE,KAA+B;AAAC;;;;;AAMtD,IAAaC,8BAAwB;CAAA,OACnCH,oBAAoBI,MAAsB;AAAC;AARf,SAAAF,MAAAvE,OAAA;CAAA,OACCA,MAAKI;AAAiB;AAMhB,SAAAqE,OAAAzE,OAAA;CAAA,OACNA,MAAKK;AAAQ"}
|
package/dist/schema-reference.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNamedType } from "graphql";
|
|
2
|
-
|
|
2
|
+
// src/schema-reference.ts
|
|
3
3
|
/**
|
|
4
4
|
* Copied from packages/codemirror-graphql/src/jump.ts
|
|
5
5
|
*/
|
|
@@ -57,7 +57,6 @@ function getEnumValueReference(typeInfo) {
|
|
|
57
57
|
function isMetaField(fieldDef) {
|
|
58
58
|
return fieldDef.name.slice(0, 2) === "__";
|
|
59
59
|
}
|
|
60
|
-
//#endregion
|
|
61
60
|
export { getSchemaReference };
|
|
62
61
|
|
|
63
62
|
//# sourceMappingURL=schema-reference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-reference.js","names":["getNamedType","
|
|
1
|
+
{"version":3,"file":"schema-reference.js","names":["getNamedType","getSchemaReference","kind","typeInfo","fieldDef","getFieldReference","directiveDef","getDirectiveReference","argDef","getArgumentReference","enumValue","getEnumValueReference","type","getTypeReference","schema","argument","directive","field","isMetaField","parentType","isObjectField","inputObjectType","value","undefined","inputType","name","slice"],"sources":["../src/schema-reference.ts"],"sourcesContent":["import { getNamedType } from 'graphql';\nimport type {\n GraphQLEnumType,\n GraphQLNamedType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLArgument,\n GraphQLDirective,\n GraphQLSchema,\n GraphQLEnumValue,\n GraphQLInputFieldMap,\n GraphQLInputType,\n GraphQLType,\n} from 'graphql';\nimport type { Maybe } from 'graphql/jsutils/Maybe';\n\n/**\n * Copied from packages/codemirror-graphql/src/jump.ts\n */\nexport function getSchemaReference(kind: string, typeInfo: any) {\n if (\n (kind === 'Field' && typeInfo.fieldDef) ||\n (kind === 'AliasedField' && typeInfo.fieldDef) ||\n (kind === 'ObjectField' && typeInfo.fieldDef)\n ) {\n return getFieldReference(typeInfo, kind === 'ObjectField');\n }\n if (kind === 'Directive' && typeInfo.directiveDef) {\n return getDirectiveReference(typeInfo);\n }\n if (kind === 'Argument' && typeInfo.argDef) {\n return getArgumentReference(typeInfo);\n }\n if (kind === 'EnumValue' && typeInfo.enumValue) {\n return getEnumValueReference(typeInfo);\n }\n if (kind === 'NamedType' && typeInfo.type) {\n return getTypeReference(typeInfo);\n }\n}\n\nfunction getArgumentReference(typeInfo: any): ArgumentReference {\n return typeInfo.directiveDef\n ? {\n kind: 'Argument',\n schema: typeInfo.schema,\n argument: typeInfo.argDef,\n directive: typeInfo.directiveDef,\n }\n : {\n kind: 'Argument',\n schema: typeInfo.schema,\n argument: typeInfo.argDef,\n field: typeInfo.fieldDef,\n type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType,\n };\n}\n\nfunction getDirectiveReference(typeInfo: any): DirectiveReference {\n return {\n kind: 'Directive',\n schema: typeInfo.schema,\n directive: typeInfo.directiveDef,\n };\n}\n\nfunction getFieldReference(\n typeInfo: any,\n isObjectField = false,\n): FieldReference {\n const type = isObjectField ? typeInfo.inputObjectType : typeInfo.parentType;\n\n return {\n kind: 'Field',\n schema: typeInfo.schema,\n field: typeInfo.fieldDef,\n type: isMetaField(typeInfo.fieldDef) ? null : type,\n };\n}\n\n// Note: for reusability, getTypeReference can produce a reference to any type,\n// though it defaults to the current type.\nfunction getTypeReference(\n typeInfo: any,\n type?: Maybe<GraphQLNamedType>,\n): TypeReference {\n return {\n kind: 'Type',\n schema: typeInfo.schema,\n type: type || typeInfo.type,\n };\n}\n\nfunction getEnumValueReference(typeInfo: TypeInfo): EnumValueReference {\n return {\n kind: 'EnumValue',\n value: typeInfo.enumValue || undefined,\n type: typeInfo.inputType\n ? (getNamedType(typeInfo.inputType) as GraphQLEnumType)\n : undefined,\n };\n}\n\nfunction isMetaField(\n fieldDef: GraphQLField<unknown, unknown> | GraphQLInputField,\n) {\n return fieldDef.name.slice(0, 2) === '__';\n}\n\ntype ArgumentReference = {\n kind: 'Argument';\n argument: GraphQLArgument;\n field?: GraphQLField<unknown, unknown>;\n type?: GraphQLNamedType;\n directive?: GraphQLDirective;\n schema?: GraphQLSchema;\n};\n\ntype DirectiveReference = {\n kind: 'Directive';\n directive: GraphQLDirective;\n schema?: GraphQLSchema;\n};\n\ntype EnumValueReference = {\n kind: 'EnumValue';\n value?: GraphQLEnumValue;\n type?: GraphQLEnumType;\n schema?: GraphQLSchema;\n};\n\ntype FieldReference = {\n kind: 'Field';\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n type: Maybe<GraphQLNamedType>;\n schema?: GraphQLSchema;\n};\n\ntype TypeReference = {\n kind: 'Type';\n type: GraphQLNamedType;\n schema?: GraphQLSchema;\n};\n\ninterface TypeInfo {\n schema: GraphQLSchema;\n type?: Maybe<GraphQLType>;\n parentType?: Maybe<GraphQLType>;\n inputType?: Maybe<GraphQLInputType>;\n inputObjectType?: Maybe<GraphQLInputObjectType>;\n directiveDef?: Maybe<GraphQLDirective>;\n fieldDef?: Maybe<GraphQLField<unknown, unknown> | GraphQLInputField>;\n argDef?: Maybe<GraphQLArgument>;\n argDefs?: Maybe<GraphQLArgument[]>;\n enumValue?: Maybe<GraphQLEnumValue>;\n objectFieldDefs?: Maybe<GraphQLInputFieldMap>;\n}\n"],"mappings":";;;;;AAoBA,SAAgBC,mBAAmBC,MAAcC,UAAe;CAC9D,IACGD,SAAS,WAAWC,SAASC,YAC7B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AA;CACN;AACF;AAEA,SAASL,YACPd,UACA;CACA,OAAOA,SAASqB,KAAKC,MAAM,GAAG,CAAC,MAAM;AACvC"}
|
package/dist/style.css
CHANGED
|
@@ -46,6 +46,18 @@ a.graphiql-doc-explorer-breadcrumb-intermediate:hover {
|
|
|
46
46
|
span.graphiql-doc-explorer-breadcrumb-current {
|
|
47
47
|
color: oklch(var(--fg-strong));
|
|
48
48
|
}
|
|
49
|
+
.graphiql-doc-explorer-deprecation {
|
|
50
|
+
background-color: oklch(var(--accent-orange) / .1);
|
|
51
|
+
border: 1px solid oklch(var(--accent-orange));
|
|
52
|
+
border-radius: var(--px-4);
|
|
53
|
+
color: oklch(var(--accent-orange));
|
|
54
|
+
padding: var(--px-8);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.graphiql-doc-explorer-deprecation-label {
|
|
58
|
+
font-size: var(--font-size-eyebrow);
|
|
59
|
+
font-weight: var(--font-weight-medium);
|
|
60
|
+
}
|
|
49
61
|
a.graphiql-doc-explorer-type-name {
|
|
50
62
|
color: oklch(var(--type-composite));
|
|
51
63
|
text-decoration: none;
|
|
@@ -70,18 +82,6 @@ a.graphiql-doc-explorer-type-name[data-type-kind="enum"] {
|
|
|
70
82
|
a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
|
|
71
83
|
color: oklch(var(--type-input));
|
|
72
84
|
}
|
|
73
|
-
.graphiql-doc-explorer-deprecation {
|
|
74
|
-
background-color: oklch(var(--accent-orange) / .1);
|
|
75
|
-
border: 1px solid oklch(var(--accent-orange));
|
|
76
|
-
border-radius: var(--px-4);
|
|
77
|
-
color: oklch(var(--accent-orange));
|
|
78
|
-
padding: var(--px-8);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.graphiql-doc-explorer-deprecation-label {
|
|
82
|
-
font-size: var(--font-size-eyebrow);
|
|
83
|
-
font-weight: var(--font-weight-medium);
|
|
84
|
-
}
|
|
85
85
|
.graphiql-doc-explorer-arguments-list {
|
|
86
86
|
padding: var(--px-4) 0;
|
|
87
87
|
flex-direction: column;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphiql/plugin-doc-explorer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@graphiql/react": "^1.0.0
|
|
35
|
+
"@graphiql/react": "^1.0.0",
|
|
36
36
|
"graphql": "^16.11.0 || ^17.0.0",
|
|
37
37
|
"react": "^18 || ^19",
|
|
38
38
|
"react-dom": "^18 || ^19"
|
|
@@ -43,28 +43,30 @@
|
|
|
43
43
|
"zustand": "^5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@storybook/addon-
|
|
49
|
-
"@storybook/
|
|
46
|
+
"@babel/core": "^7.29.6",
|
|
47
|
+
"@graphiql/react": "^1.0.0",
|
|
48
|
+
"@storybook/addon-a11y": "^10.6.9",
|
|
49
|
+
"@storybook/addon-vitest": "^10.6.9",
|
|
50
|
+
"@storybook/react-vite": "^10.6.9",
|
|
50
51
|
"@testing-library/dom": "^10.4.0",
|
|
51
|
-
"@testing-library/jest-dom": "^
|
|
52
|
+
"@testing-library/jest-dom": "^8.0.0",
|
|
52
53
|
"@testing-library/react": "^16.3.0",
|
|
53
54
|
"@types/react": "^19",
|
|
54
55
|
"@types/react-dom": "^19",
|
|
55
56
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
56
|
-
"@vitejs/plugin-react": "^
|
|
57
|
-
"@vitest/web-worker": "^5.
|
|
57
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
58
|
+
"@vitest/web-worker": "^5.1.2",
|
|
58
59
|
"babel-plugin-react-compiler": "1.0.0",
|
|
59
|
-
"graphql": "^17.0
|
|
60
|
-
"monaco-editor": ">=0.56.0 <0.
|
|
60
|
+
"graphql": "^17.1.0",
|
|
61
|
+
"monaco-editor": ">=0.56.0 <0.59.0",
|
|
61
62
|
"react": "^19.1.0",
|
|
62
63
|
"react-dom": "^19.1.0",
|
|
63
|
-
"storybook": "^10.6.
|
|
64
|
-
"vite": "^8.
|
|
65
|
-
"vite-plugin-dts": "^
|
|
64
|
+
"storybook": "^10.6.9",
|
|
65
|
+
"vite": "^8.4.0",
|
|
66
|
+
"vite-plugin-dts": "^5.1.2",
|
|
66
67
|
"vitest-canvas-mock": "^1.2.0",
|
|
67
|
-
"typescript": "
|
|
68
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
69
|
+
"@rolldown/plugin-babel": "^0.3.2"
|
|
68
70
|
},
|
|
69
71
|
"scripts": {
|
|
70
72
|
"types:check": "tsc --noEmit",
|