@graphiql/plugin-doc-explorer 1.0.0 → 1.0.2

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.
Files changed (46) hide show
  1. package/dist/components/argument.js +3 -4
  2. package/dist/components/argument.js.map +1 -1
  3. package/dist/components/arguments-list.js +66 -69
  4. package/dist/components/arguments-list.js.map +1 -1
  5. package/dist/components/breadcrumb.js +2 -3
  6. package/dist/components/breadcrumb.js.map +1 -1
  7. package/dist/components/default-value.d.ts +8 -0
  8. package/dist/components/default-value.js +38 -28
  9. package/dist/components/default-value.js.map +1 -1
  10. package/dist/components/deprecation-reason.js +2 -3
  11. package/dist/components/deprecation-reason.js.map +1 -1
  12. package/dist/components/directive.js +2 -3
  13. package/dist/components/directive.js.map +1 -1
  14. package/dist/components/doc-explorer.js +5 -6
  15. package/dist/components/doc-explorer.js.map +1 -1
  16. package/dist/components/field-card.js +4 -5
  17. package/dist/components/field-card.js.map +1 -1
  18. package/dist/components/field-documentation.js +3 -4
  19. package/dist/components/field-documentation.js.map +1 -1
  20. package/dist/components/field-link.js +2 -3
  21. package/dist/components/field-link.js.map +1 -1
  22. package/dist/components/fields-list.js +6 -7
  23. package/dist/components/fields-list.js.map +1 -1
  24. package/dist/components/schema-documentation.js +4 -5
  25. package/dist/components/schema-documentation.js.map +1 -1
  26. package/dist/components/search-row.js +71 -85
  27. package/dist/components/search-row.js.map +1 -1
  28. package/dist/components/search.js +107 -123
  29. package/dist/components/search.js.map +1 -1
  30. package/dist/components/section.js +2 -3
  31. package/dist/components/section.js.map +1 -1
  32. package/dist/components/type-card.js +3 -4
  33. package/dist/components/type-card.js.map +1 -1
  34. package/dist/components/type-documentation.js +7 -8
  35. package/dist/components/type-documentation.js.map +1 -1
  36. package/dist/components/type-link.js +3 -4
  37. package/dist/components/type-link.js.map +1 -1
  38. package/dist/components/utils.js +1 -2
  39. package/dist/components/utils.js.map +1 -1
  40. package/dist/context.d.ts +3 -1
  41. package/dist/context.js +23 -20
  42. package/dist/context.js.map +1 -1
  43. package/dist/schema-reference.js +1 -2
  44. package/dist/schema-reference.js.map +1 -1
  45. package/dist/style.css +42 -119
  46. package/package.json +18 -16
@@ -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;C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GAAxBA,QAAKrB,IAAmB;AAAI;AA8BJ,SAAA4B,OAAAQ,OAAA;CAAA,OAChBA,MAAKT;AAAO;AADI,SAAAG,OAAAO,cAAA;CAAA,OAU9C,oBAAA,OAAA,EAAA,UACE,oBAAC,UAAD,EAAgBA,MAAAA,aAAY,CAAA,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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,SAAAwB,OAAAW,SAAA;CAAA,OAiCrCK,oBAAC,WAAD,EAAmCnB,OAAAA,QAAO,GAA1BA,QAAKrB,IAAqB;AAAE;AA8BJ,SAAA4B,OAAAQ,OAAA;CAAA,OAChBA,MAAKT;AAAO;AADI,SAAAG,OAAAO,cAAA;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
- //#region src/components/type-link.tsx
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":["FC","GraphQLType","typeCategory","useDocExplorerActions","renderType","TypeLinkProps","type","TypeLink","t0","$","_c","push","t1","def","event","preventDefault","name","t2"],"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,IAAaO,YAA8BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAJ,SAAAE;CAC1C,MAAA,EAAAG,SAAiBR,sBAAsB;CAAE,IAAAS;CAAA,IAAAH,EAAA,OAAAE,MAAA;EAEjBC,MAAAC,QACtB,oBAAA,KAAA;GACY,WAAA;GACM,kBAAAX,aAAaW,GAAG;GACvB,UAAAC,UAAA;IACPA,MAAKC,eAAgB;IACrBJ,KAAK;KAAAK,MAAQH,IAAGG;KAAKH;IAAM,CAAC;GAAC;GAE1B,MAAA;GAEJA,UAAAA,IAAGG;EACF,CAAA;EACLP,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAG,MAAAH,EAAA,OAAAH,MAAA;EAZMW,KAAAb,WAAWE,MAAMM,EAYvB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAH;EAAAG,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAZKQ;AAYL"}
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"}
@@ -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
- //#region src/components/utils.tsx
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":["GraphQLNamedType","GraphQLType","isListType","isNonNullType","JSX","renderType","type","renderNamedType","namedType","Element","ofType"],"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,SAAgBK,WACdC,MACAC,iBACa;CACb,IAAIJ,cAAcG,IAAI,GACpB,OAAO,qBAAA,UAAA,EAAA,UAAA,CAAGD,WAAWC,KAAKI,QAAQH,eAAe,GAAE,GAAC,EAAA,CAAA;CAEtD,IAAIL,WAAWI,IAAI,GACjB,OAAO,qBAAA,UAAA,EAAA,UAAA;EAAE;EAAED,WAAWC,KAAKI,QAAQH,eAAe;EAAE;CAAC,EAAA,CAAA;CAEvD,OAAOA,gBAAgBD,IAAI;AAC7B"}
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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType, GraphQLSchema } from 'graphql';
2
- import { FC, ReactNode } from 'react';
2
+ import { FC, ReactNode, RefObject } from 'react';
3
3
  import { SchemaReference, GraphiQLPlugin } from '@graphiql/react';
4
4
  export declare const DOC_EXPLORER_PLUGIN: GraphiQLPlugin;
5
5
  export type DocExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
@@ -49,6 +49,8 @@ export type DocExplorerStoreType = {
49
49
  export declare const docExplorerStore: import('zustand').StoreApi<DocExplorerStoreType>;
50
50
  export declare const DocExplorerStore: FC<{
51
51
  children: ReactNode;
52
+ /** The container in which Cmd/Ctrl+K opens documentation search. */
53
+ shortcutTarget?: RefObject<HTMLElement | null>;
52
54
  }>;
53
55
  export declare const useDocExplorer: () => DocExplorerNavStack;
54
56
  /**
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
- //#region src/context.tsx
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() {
@@ -117,17 +117,17 @@ var docExplorerStore = createStore((set) => ({
117
117
  }
118
118
  }
119
119
  }));
120
- function focusSearchInputWhenMounted(framesLeft) {
120
+ function focusSearchInputWhenMounted(container, framesLeft) {
121
121
  if (framesLeft <= 0) return;
122
122
  requestAnimationFrame(() => {
123
- const el = document.querySelector(".graphiql-doc-explorer-search-row-input");
123
+ const el = container.querySelector(".graphiql-doc-explorer-search-row-input");
124
124
  if (el) el.click();
125
- else focusSearchInputWhenMounted(framesLeft - 1);
125
+ else focusSearchInputWhenMounted(container, framesLeft - 1);
126
126
  });
127
127
  }
128
128
  var DocExplorerStore = (t0) => {
129
- const $ = c(11);
130
- const { children } = t0;
129
+ const $ = c(12);
130
+ const { children, shortcutTarget } = t0;
131
131
  let t1;
132
132
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
133
133
  t1 = pick("schema", "validationErrors", "schemaReference");
@@ -171,27 +171,31 @@ var DocExplorerStore = (t0) => {
171
171
  useEffect(t4, t5);
172
172
  let t6;
173
173
  let t7;
174
- if ($[8] !== setVisiblePlugin) {
174
+ if ($[8] !== setVisiblePlugin || $[9] !== shortcutTarget) {
175
175
  t6 = () => {
176
+ const target = shortcutTarget?.current ?? document.documentElement;
176
177
  const handleKeyDown = function handleKeyDown(event) {
177
178
  if (!(event[isMacOs ? "metaKey" : "ctrlKey"] && event.code === "KeyK")) return;
179
+ const container = event.target instanceof Element ? event.target.closest(".graphiql-container") : null;
180
+ if (!container || shortcutTarget && container !== shortcutTarget.current) return;
178
181
  event.preventDefault();
179
182
  event.stopPropagation();
180
183
  setVisiblePlugin(DOC_EXPLORER_PLUGIN);
181
- focusSearchInputWhenMounted(10);
184
+ focusSearchInputWhenMounted(container, 10);
182
185
  };
183
- window.addEventListener("keydown", handleKeyDown, true);
186
+ target.addEventListener("keydown", handleKeyDown, true);
184
187
  return () => {
185
- window.removeEventListener("keydown", handleKeyDown, true);
188
+ target.removeEventListener("keydown", handleKeyDown, true);
186
189
  };
187
190
  };
188
- t7 = [setVisiblePlugin];
191
+ t7 = [setVisiblePlugin, shortcutTarget];
189
192
  $[8] = setVisiblePlugin;
190
- $[9] = t6;
191
- $[10] = t7;
193
+ $[9] = shortcutTarget;
194
+ $[10] = t6;
195
+ $[11] = t7;
192
196
  } else {
193
- t6 = $[9];
194
- t7 = $[10];
197
+ t6 = $[10];
198
+ t7 = $[11];
195
199
  }
196
200
  useEffect(t6, t7);
197
201
  return children;
@@ -213,7 +217,6 @@ function _temp(state) {
213
217
  function _temp2(state) {
214
218
  return state.actions;
215
219
  }
216
- //#endregion
217
220
  export { DOC_EXPLORER_PLUGIN, DocExplorerStore, docExplorerStore, useDocExplorer, useDocExplorerActions };
218
221
 
219
222
  //# sourceMappingURL=context.js.map
@@ -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,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gBAAiB;IAEtBb,iBAAiB/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","container","Element","framesLeft","requestAnimationFrame","el","querySelector","click","DocExplorerStore","children","shortcutTarget","t0","$","_c","t1","Symbol","for","validationErrors","setVisiblePlugin","t2","t3","getState","t4","t5","t6","t7","target","current","document","documentElement","handleKeyDown","event","code","closest","preventDefault","stopPropagation","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, RefObject, 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(container: Element, framesLeft: number) {\n if (framesLeft <= 0) {\n return;\n }\n requestAnimationFrame(() => {\n const el = container.querySelector<HTMLDivElement>(\n '.graphiql-doc-explorer-search-row-input',\n );\n if (el) {\n el.click();\n } else {\n focusSearchInputWhenMounted(container, framesLeft - 1);\n }\n });\n}\n\nexport const DocExplorerStore: FC<{\n children: ReactNode;\n /** The container in which Cmd/Ctrl+K opens documentation search. */\n shortcutTarget?: RefObject<HTMLElement | null>;\n}> = ({ children, shortcutTarget }) => {\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 const target = shortcutTarget?.current ?? document.documentElement;\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 const container =\n event.target instanceof Element\n ? event.target.closest('.graphiql-container')\n : null;\n if (\n !container ||\n (shortcutTarget && container !== shortcutTarget.current)\n ) {\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(container, 10);\n }\n\n target.addEventListener('keydown', handleKeyDown, true);\n return () => {\n target.removeEventListener('keydown', handleKeyDown, true);\n };\n }, [setVisiblePlugin, shortcutTarget]);\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,sBACvBqF,oBAAC,gBAAD,CAAgB,CAAA,IAEhBA,oBAAC,UAAD,CAAU,CAAA;CAEd;CACA/E,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,C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,MAAAC,gBAAA,SAAAA,cAAAC,OAAA;IAME,IAAI,EAJFA,MAAM7E,UAAA,YAAA,cAGN6E,MAAKC,SAAU,SACI;IAGrB,MAAA/B,YACE8B,MAAKL,kBAAmBxB,UACpB6B,MAAKL,OAAOO,QAAS,qBAClB,IAFP;IAGF,IACE,CAAChC,aACAS,kBAAkBT,cAAcS,eAAciB,SAAS;IAM1DI,MAAKG,eAAgB;IACrBH,MAAKI,gBAAiB;IAEtBjB,iBAAiB5D,mBAAmB;IAIpC0C,4BAA4BC,WAAW,EAAE;GAAC;GAG5CyB,OAAMU,iBAAkB,WAAWN,eAAe,IAAI;GAAC,aAChD;IACLJ,OAAMW,oBAAqB,WAAWP,eAAe,IAAI;GAAC;EAC3D;EACAL,KAAA,CAACP,kBAAkBR,cAAc;EAACE,EAAA,KAAAM;EAAAN,EAAA,KAAAF;EAAAE,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAD,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CArCrC/D,UAAU2E,IAqCPC,EAAkC;CAAC,OAE/BhB;AAAwB;AAGjC,IAAM6B,sBAAsBrF,sBAAsByB,gBAAgB;AAElE,IAAa6D,uBAAiB;CAAA,OAC5BD,oBAAoBE,KAA+B;AAAC;;;;;AAMtD,IAAaC,8BAAwB;CAAA,OACnCH,oBAAoBI,MAAsB;AAAC;AARf,SAAAF,MAAA7E,OAAA;CAAA,OACCA,MAAKI;AAAiB;AAMhB,SAAA2E,OAAA/E,OAAA;CAAA,OACNA,MAAKK;AAAQ"}
@@ -1,5 +1,5 @@
1
1
  import { getNamedType } from "graphql";
2
- //#region src/schema-reference.ts
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","GraphQLEnumType","GraphQLNamedType","GraphQLField","GraphQLInputField","GraphQLInputObjectType","GraphQLArgument","GraphQLDirective","GraphQLSchema","GraphQLEnumValue","GraphQLInputFieldMap","GraphQLInputType","GraphQLType","Maybe","getSchemaReference","kind","typeInfo","fieldDef","getFieldReference","directiveDef","getDirectiveReference","argDef","getArgumentReference","enumValue","getEnumValueReference","type","getTypeReference","ArgumentReference","schema","argument","directive","field","isMetaField","parentType","DirectiveReference","isObjectField","FieldReference","inputObjectType","TypeReference","TypeInfo","EnumValueReference","value","undefined","inputType","name","slice","argDefs","objectFieldDefs"],"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,YAC7BF,SAAS,kBAAkBC,SAASC,YACpCF,SAAS,iBAAiBC,SAASC,UAEpC,OAAOC,kBAAkBF,UAAUD,SAAS,aAAa;CAE3D,IAAIA,SAAS,eAAeC,SAASG,cACnC,OAAOC,sBAAsBJ,QAAQ;CAEvC,IAAID,SAAS,cAAcC,SAASK,QAClC,OAAOC,qBAAqBN,QAAQ;CAEtC,IAAID,SAAS,eAAeC,SAASO,WACnC,OAAOC,sBAAsBR,QAAQ;CAEvC,IAAID,SAAS,eAAeC,SAASS,MACnC,OAAOC,iBAAiBV,QAAQ;AAEpC;AAEA,SAASM,qBAAqBN,UAAkC;CAC9D,OAAOA,SAASG,eACZ;EACEJ,MAAM;EACNa,QAAQZ,SAASY;EACjBC,UAAUb,SAASK;EACnBS,WAAWd,SAASG;CACtB,IACA;EACEJ,MAAM;EACNa,QAAQZ,SAASY;EACjBC,UAAUb,SAASK;EACnBU,OAAOf,SAASC;EAChBQ,MAAMO,YAAYhB,SAASC,QAAQ,IAAI,OAAOD,SAASiB;CACzD;AACN;AAEA,SAASb,sBAAsBJ,UAAmC;CAChE,OAAO;EACLD,MAAM;EACNa,QAAQZ,SAASY;EACjBE,WAAWd,SAASG;CACtB;AACF;AAEA,SAASD,kBACPF,UACAmB,gBAAgB,OACA;CAChB,MAAMV,OAAOU,gBAAgBnB,SAASqB,kBAAkBrB,SAASiB;CAEjE,OAAO;EACLlB,MAAM;EACNa,QAAQZ,SAASY;EACjBG,OAAOf,SAASC;EAChBQ,MAAMO,YAAYhB,SAASC,QAAQ,IAAI,OAAOQ;CAChD;AACF;AAIA,SAASC,iBACPV,UACAS,MACe;CACf,OAAO;EACLV,MAAM;EACNa,QAAQZ,SAASY;EACjBH,MAAMA,QAAQT,SAASS;CACzB;AACF;AAEA,SAASD,sBAAsBR,UAAwC;CACrE,OAAO;EACLD,MAAM;EACN0B,OAAOzB,SAASO,aAAamB,KAAAA;EAC7BjB,MAAMT,SAAS2B,YACV3C,aAAagB,SAAS2B,SAAS,IAChCD,KAAAA;CACN;AACF;AAEA,SAASV,YACPf,UACA;CACA,OAAOA,SAAS2B,KAAKC,MAAM,GAAG,CAAC,MAAM;AACvC"}
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,YAC7BF,SAAS,kBAAkBC,SAASC,YACpCF,SAAS,iBAAiBC,SAASC,UAEpC,OAAOC,kBAAkBF,UAAUD,SAAS,aAAa;CAE3D,IAAIA,SAAS,eAAeC,SAASG,cACnC,OAAOC,sBAAsBJ,QAAQ;CAEvC,IAAID,SAAS,cAAcC,SAASK,QAClC,OAAOC,qBAA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